@vibgrate/cli 2026.819.3 → 2026.825.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.
- package/dist/{agent-AFMDB4GM.js → agent-IHNUBFBM.js} +13 -12
- package/dist/{agent-AFMDB4GM.js.map → agent-IHNUBFBM.js.map} +1 -1
- package/dist/{approvals-F2DJGPU7.js → approvals-HRIMDIX3.js} +5 -5
- package/dist/{approvals-F2DJGPU7.js.map → approvals-HRIMDIX3.js.map} +1 -1
- package/dist/{attach-XTX2Q3AD.js → attach-L43JUJ7A.js} +3 -3
- package/dist/{attach-XTX2Q3AD.js.map → attach-L43JUJ7A.js.map} +1 -1
- package/dist/{baseline-KTE2C3LW.js → baseline-EZQ7SCRT.js} +3 -3
- package/dist/{baseline-KTE2C3LW.js.map → baseline-EZQ7SCRT.js.map} +1 -1
- package/dist/{chunk-TD4JAEMH.js → chunk-4PCFSRYH.js} +5 -5
- package/dist/{chunk-TD4JAEMH.js.map → chunk-4PCFSRYH.js.map} +1 -1
- package/dist/{chunk-ARGYMFST.js → chunk-5BFA532E.js} +3 -3
- package/dist/{chunk-ARGYMFST.js.map → chunk-5BFA532E.js.map} +1 -1
- package/dist/{chunk-UAPA5AHX.js → chunk-6VLOI2ZP.js} +35 -14
- package/dist/chunk-6VLOI2ZP.js.map +1 -0
- package/dist/{chunk-DMI4BMUL.js → chunk-B5X246UH.js} +3 -3
- package/dist/{chunk-DMI4BMUL.js.map → chunk-B5X246UH.js.map} +1 -1
- package/dist/{chunk-3XMTRK24.js → chunk-BCK2NIBM.js} +6 -6
- package/dist/{chunk-3XMTRK24.js.map → chunk-BCK2NIBM.js.map} +1 -1
- package/dist/{chunk-SOAEPTSW.js → chunk-CIC3NY2D.js} +60 -24
- package/dist/chunk-CIC3NY2D.js.map +1 -0
- package/dist/{chunk-XZDI2N7M.js → chunk-DLNNNESQ.js} +3 -3
- package/dist/{chunk-XZDI2N7M.js.map → chunk-DLNNNESQ.js.map} +1 -1
- package/dist/{chunk-5R4HYDTC.js → chunk-ECQFRZJI.js} +4 -4
- package/dist/{chunk-5R4HYDTC.js.map → chunk-ECQFRZJI.js.map} +1 -1
- package/dist/{chunk-C5AOLTQS.js → chunk-FVBN4E5C.js} +53 -463
- package/dist/chunk-FVBN4E5C.js.map +1 -0
- package/dist/{chunk-UEXDSWKN.js → chunk-GRMZU24V.js} +3 -3
- package/dist/{chunk-UEXDSWKN.js.map → chunk-GRMZU24V.js.map} +1 -1
- package/dist/{chunk-CEJIX3O7.js → chunk-JSZ46IDG.js} +6 -6
- package/dist/{chunk-CEJIX3O7.js.map → chunk-JSZ46IDG.js.map} +1 -1
- package/dist/chunk-KFLNWYZG.js +6 -0
- package/dist/{chunk-MQJY4EQV.js.map → chunk-KFLNWYZG.js.map} +1 -1
- package/dist/{chunk-WI66PODG.js → chunk-L3YEEJ6U.js} +25 -5
- package/dist/chunk-L3YEEJ6U.js.map +1 -0
- package/dist/{chunk-XAS45W3G.js → chunk-LKJIYGO5.js} +11 -12
- package/dist/chunk-LKJIYGO5.js.map +1 -0
- package/dist/chunk-LUJ4H4RJ.js +605 -0
- package/dist/chunk-LUJ4H4RJ.js.map +1 -0
- package/dist/{chunk-5RMME7PT.js → chunk-M7O6IVKN.js} +3 -3
- package/dist/{chunk-5RMME7PT.js.map → chunk-M7O6IVKN.js.map} +1 -1
- package/dist/{chunk-3SOJZ3VV.js → chunk-QTQRM7HQ.js} +3 -3
- package/dist/{chunk-3SOJZ3VV.js.map → chunk-QTQRM7HQ.js.map} +1 -1
- package/dist/{chunk-PQISIPYP.js → chunk-RHYRMMN3.js} +3 -3
- package/dist/{chunk-PQISIPYP.js.map → chunk-RHYRMMN3.js.map} +1 -1
- package/dist/{chunk-HRYF4PWE.js → chunk-S3HMG6BC.js} +3 -3
- package/dist/{chunk-HRYF4PWE.js.map → chunk-S3HMG6BC.js.map} +1 -1
- package/dist/{chunk-QOU2Q5L4.js → chunk-TLYNLQL2.js} +221 -10
- package/dist/chunk-TLYNLQL2.js.map +1 -0
- package/dist/{chunk-EXFA7QFC.js → chunk-UUVOA6WD.js} +10 -8
- package/dist/chunk-UUVOA6WD.js.map +1 -0
- package/dist/{chunk-UP2BR6TV.js → chunk-X34HVFZ6.js} +8 -8
- package/dist/{chunk-UP2BR6TV.js.map → chunk-X34HVFZ6.js.map} +1 -1
- package/dist/{chunk-HVJHFTIV.js → chunk-Y3X3ORQ3.js} +10 -12
- package/dist/chunk-Y3X3ORQ3.js.map +1 -0
- package/dist/{chunk-HB3SONYP.js → chunk-YIRDV4YJ.js} +3 -3
- package/dist/{chunk-HB3SONYP.js.map → chunk-YIRDV4YJ.js.map} +1 -1
- package/dist/chunk-YP243ZKD.js +90 -0
- package/dist/chunk-YP243ZKD.js.map +1 -0
- package/dist/cli.js +381 -542
- package/dist/cli.js.map +1 -1
- package/dist/{daemon-VMQKIIYP.js → daemon-WPX2SBVV.js} +9 -9
- package/dist/{daemon-VMQKIIYP.js.map → daemon-WPX2SBVV.js.map} +1 -1
- package/dist/embed-worker-main.js +3 -3
- package/dist/{ensure-map-YIUJWMBK.js → ensure-map-MLI4XCRV.js} +14 -14
- package/dist/{ensure-map-YIUJWMBK.js.map → ensure-map-MLI4XCRV.js.map} +1 -1
- package/dist/{graph-backend-FDZUY4TR.js → graph-backend-LK5EFQXN.js} +7 -7
- package/dist/{graph-backend-FDZUY4TR.js.map → graph-backend-LK5EFQXN.js.map} +1 -1
- package/dist/index.d.ts +115 -132
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/{interactive-CS4PGZPK.js → interactive-K446F42I.js} +27 -25
- package/dist/interactive-K446F42I.js.map +1 -0
- package/dist/load-2FRH37JY.js +11 -0
- package/dist/{load-4EY64JJO.js.map → load-2FRH37JY.js.map} +1 -1
- package/dist/parse-worker.js +3 -2
- package/dist/parse-worker.js.map +1 -1
- package/dist/{run-outcome-T7VDBNWB.js → run-outcome-4ETNDPX6.js} +5 -5
- package/dist/{run-outcome-T7VDBNWB.js.map → run-outcome-4ETNDPX6.js.map} +1 -1
- package/dist/{runtime-session-WZLVADPQ.js → runtime-session-RMSKXFIJ.js} +9 -9
- package/dist/{runtime-session-WZLVADPQ.js.map → runtime-session-RMSKXFIJ.js.map} +1 -1
- package/dist/{session-VPP2VGUN.js → session-22BGDYWF.js} +8 -8
- package/dist/{session-VPP2VGUN.js.map → session-22BGDYWF.js.map} +1 -1
- package/dist/{stream-json-XXCFN4MF.js → stream-json-MD7MSSCH.js} +13 -12
- package/dist/stream-json-MD7MSSCH.js.map +1 -0
- package/dist/version-FRUT6RI2.js +4 -0
- package/dist/{version-2UBJ7N2I.js.map → version-FRUT6RI2.js.map} +1 -1
- package/dist/{vg-mcp-bridge-H6GXYNKV.js → vg-mcp-bridge-H6I3ALUW.js} +8 -8
- package/dist/{vg-mcp-bridge-H6GXYNKV.js.map → vg-mcp-bridge-H6I3ALUW.js.map} +1 -1
- package/dist/{vgd-SBZO4ONQ.js → vgd-TW7HU2PH.js} +8 -8
- package/dist/vgd-TW7HU2PH.js.map +1 -0
- package/package.json +2 -4
- package/dist/chunk-C5AOLTQS.js.map +0 -1
- package/dist/chunk-EXFA7QFC.js.map +0 -1
- package/dist/chunk-HVJHFTIV.js.map +0 -1
- package/dist/chunk-MQJY4EQV.js +0 -6
- package/dist/chunk-QOU2Q5L4.js.map +0 -1
- package/dist/chunk-SOAEPTSW.js.map +0 -1
- package/dist/chunk-UAPA5AHX.js.map +0 -1
- package/dist/chunk-VEQA2FSM.js +0 -699
- package/dist/chunk-VEQA2FSM.js.map +0 -1
- package/dist/chunk-WI66PODG.js.map +0 -1
- package/dist/chunk-XAS45W3G.js.map +0 -1
- package/dist/interactive-CS4PGZPK.js.map +0 -1
- package/dist/load-4EY64JJO.js +0 -11
- package/dist/stream-json-XXCFN4MF.js.map +0 -1
- package/dist/version-2UBJ7N2I.js +0 -4
- package/dist/vgd-SBZO4ONQ.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { fetchCatalog, resolveProviders } from './chunk-
|
|
3
|
-
import { telemetryOptOut, StatsSharer, statsEndpoint, isCI } from './chunk-
|
|
2
|
+
import { fetchCatalog, resolveProviders } from './chunk-DLNNNESQ.js';
|
|
3
|
+
import { telemetryOptOut, StatsSharer, statsEndpoint, isCI } from './chunk-M7O6IVKN.js';
|
|
4
4
|
import { loadAdvancedScanHook, baselineCommand } from './chunk-QLNJ3VWO.js';
|
|
5
|
-
import { sha256Hex, generateKeypair, dssePae, DSSE_PAYLOAD_TYPE, keyId, registerBuild, LiveStatus, ProgressBar, printLogo, runBuild } from './chunk-
|
|
6
|
-
export { runBuild } from './chunk-
|
|
5
|
+
import { sha256Hex, generateKeypair, dssePae, DSSE_PAYLOAD_TYPE, keyId, registerBuild, LiveStatus, ProgressBar, printLogo, runBuild } from './chunk-X34HVFZ6.js';
|
|
6
|
+
export { runBuild } from './chunk-X34HVFZ6.js';
|
|
7
7
|
import { readOrchestratorState, writeOrchestratorState, parseMode, setDefaultMode, recommendMode, activePin, resolveMode, providerForBackend, QUALIFIED_PACKS, pinPack, unpinPack, buildOrchestratorStatus } from './chunk-OLIMW4PQ.js';
|
|
8
8
|
import { defaultProcessEndpoint, startProcessHostServer, resolveInferenceIsolation } from './chunk-IASO2HCI.js';
|
|
9
|
-
import { runCodeSession } from './chunk-
|
|
10
|
-
import { CONTEXT_POLICY_VERSION, computeFcsReport, renderFcsReportMarkdown, createTrajectoryCollector, runAgent } from './chunk-
|
|
9
|
+
import { runCodeSession } from './chunk-Y3X3ORQ3.js';
|
|
10
|
+
import { CONTEXT_POLICY_VERSION, computeFcsReport, renderFcsReportMarkdown, createTrajectoryCollector, runAgent } from './chunk-CIC3NY2D.js';
|
|
11
11
|
import './chunk-543E6WDJ.js';
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
12
|
+
import './chunk-QTQRM7HQ.js';
|
|
13
|
+
import './chunk-YIRDV4YJ.js';
|
|
14
14
|
import { parseReasoningEffort, summarizeDiffs, ScriptedProvider } from './chunk-SHD5TCZ5.js';
|
|
15
15
|
import './chunk-NV7XNBX4.js';
|
|
16
16
|
import { buildModelInstallPlan } from './chunk-W44THEXF.js';
|
|
17
17
|
import { ensurePackage, ensureUnavailableMessage } from './chunk-3HNPVXUK.js';
|
|
18
|
-
import { vgdVersionSkew, restartVgdIfRunning, stopVgd, registerDaemon, rootOf, requireGraph } from './chunk-
|
|
18
|
+
import { vgdVersionSkew, restartVgdIfRunning, stopVgd, registerDaemon, rootOf, requireGraph } from './chunk-BCK2NIBM.js';
|
|
19
19
|
import { readGlobal, applyGlobalOptions } from './chunk-YENM3HT7.js';
|
|
20
20
|
import { ActivityLog } from './chunk-H5Q4JUY4.js';
|
|
21
21
|
import { disableColor, info, c, json, out } from './chunk-CT5BS56U.js';
|
|
22
22
|
import { init_resolve_ollama, gatherSystemMemory, resolveOllamaBinary, hasOllamaBinary, resolve_ollama_exports } from './chunk-WUFIXAEJ.js';
|
|
23
23
|
import { fmt, estimateModelBytes } from './chunk-YJYEPYB2.js';
|
|
24
|
-
import { isManifest, isDependencyFile, manifestHash, loadScanCache, writeScanCache, manifestKind, findPackageLine, endOfLine, findRuntimeLine } from './chunk-
|
|
24
|
+
import { isManifest, isDependencyFile, manifestHash, loadScanCache, writeScanCache, manifestKind, findPackageLine, endOfLine, findRuntimeLine } from './chunk-JSZ46IDG.js';
|
|
25
25
|
import { clearHostSessionPool, acquireHostSession, generateOnSession, listHostSessions, hostSessionPoolSize } from './chunk-3LOWJSAF.js';
|
|
26
26
|
import { buildIdentifierTrieFromGraph } from './chunk-5HYCB55P.js';
|
|
27
27
|
import './chunk-IS7VTH2Q.js';
|
|
28
28
|
import './chunk-IZDH67DX.js';
|
|
29
|
-
import { DaemonSemanticSession, serveStdio, exportGraph, GraphSource, createServer, formatForExt, RefreshScheduler } from './chunk-
|
|
30
|
-
import { refreshIfStale } from './chunk-
|
|
31
|
-
import { driftCount, ASSISTANTS, detectAssistants, isAssistantInstalled, detectServeLaunch, installAssistant, writeNavigationConfig, uninstallAssistant, buildGraph, writeSnapshot, probeFreshness, assistantById, SMALL_REPO_FILES } from './chunk-
|
|
32
|
-
import { resolveDsn, createWorkspaceDsn, writeStoredCredentials, credentialsPath, findGitRoot, ensureGitignored, gitignoreEntryForCredentials, clearStoredCredentials, parseDsn as parseDsn$1, uploadScanArtifact, dsnCommand, pushCommand, countTokens, shortestPath, pathDisconnect, testsToRun, detectRunner, coveringTests, FREE_PACK, readScanArtifact, publishPrivateLibrary, assessDocQuality, symbolsFromApi, fetchHostedDocsCached, selectForBudget, hostedBase, readStoredCredentials, projectCredentialsPath, homeCredentialsPath } from './chunk-
|
|
29
|
+
import { moduleInstalled, removeRelevanceModule, installRelevanceModule, DISCLOSURE, RELEVANCE_MODULE_NAME, moduleInstalledAt, removeModule, installModule, kickRelevanceReadiness, modulesBaseDir, ensureRelevanceModule, DaemonSemanticSession, serveStdio, kernelDisabled, writeConsent, readConsent, exportGraph, GraphSource, createServer, formatForExt, RefreshScheduler } from './chunk-TLYNLQL2.js';
|
|
30
|
+
import { refreshIfStale } from './chunk-4PCFSRYH.js';
|
|
31
|
+
import { driftCount, ASSISTANTS, detectAssistants, isAssistantInstalled, detectServeLaunch, installAssistant, writeNavigationConfig, uninstallAssistant, buildGraph, writeSnapshot, probeFreshness, assistantById, SMALL_REPO_FILES } from './chunk-UUVOA6WD.js';
|
|
32
|
+
import { resolveDsn, createWorkspaceDsn, writeStoredCredentials, credentialsPath, findGitRoot, ensureGitignored, gitignoreEntryForCredentials, clearStoredCredentials, parseDsn as parseDsn$1, uploadScanArtifact, dsnCommand, pushCommand, countTokens, shortestPath, pathDisconnect, testsToRun, detectRunner, coveringTests, FREE_PACK, readScanArtifact, publishPrivateLibrary, assessDocQuality, symbolsFromApi, fetchHostedDocsCached, selectForBudget, hostedBase, readStoredCredentials, projectCredentialsPath, homeCredentialsPath } from './chunk-LKJIYGO5.js';
|
|
33
33
|
import { resolveIngestHost, dashHostForIngestHost, availableRegionIds, ingestHostForRegionId } from './chunk-HTLDXEHW.js';
|
|
34
34
|
import { writeDefaultConfig, parseDsn, detectVcs, computeRepoFingerprint, resolveRepositoryName, fetchScanPreflight, runCoreScan, loadConfig, prepareCompressedUpload, computeDriftScore, titleBox, projectTypeToVulnEcosystem, driftBar, gitHistoryAvailable, buildVersionTimelines, findPackageAnyEcosystem, normalizeConstraint, findVersionCrossings, versionSatisfies, refineArchitectureWithAstRoles, refineArchitectureWithGraph, PROJECT_TYPE_TO_OSV_ECOSYSTEM, fetchRiskySymbols, perDependencyDrift, boundaryProfileRules } from './chunk-5UG4UHKU.js';
|
|
35
|
+
import './chunk-YP243ZKD.js';
|
|
35
36
|
import './chunk-VIWZ4QT7.js';
|
|
36
|
-
import { catalogPath, libDir, loadCatalog, driftFor, addLibrary, resolveLib, libId, resolveVersion, readDoc, localPackageDocs, localApiSurface } from './chunk-
|
|
37
|
-
import { recordCliCall, CLI_TOOL_ALIASES, savingsLedgerPath, clearSavings, readSavings, readUsage, readModelSavings, CAPSULE_RANKING_VERSION, SAVINGS_TOOLS, sanitizeClient } from './chunk-
|
|
37
|
+
import { catalogPath, libDir, loadCatalog, driftFor, addLibrary, resolveLib, libId, resolveVersion, readDoc, localPackageDocs, localApiSurface } from './chunk-S3HMG6BC.js';
|
|
38
|
+
import { recordCliCall, CLI_TOOL_ALIASES, savingsLedgerPath, clearSavings, readSavings, readUsage, readModelSavings, CAPSULE_RANKING_VERSION, SAVINGS_TOOLS, sanitizeClient } from './chunk-6VLOI2ZP.js';
|
|
38
39
|
import { discoverModels } from './chunk-WNKGRXUA.js';
|
|
39
40
|
import { freeBytesOnVolume, weightStoreDir, listCachedWeights, ensureWeightCached, catalogIntegrityReport } from './chunk-57ZRSCHY.js';
|
|
40
41
|
import { CliError, ExitCode, usageError, engineUnavailable } from './chunk-MS6V5XKB.js';
|
|
41
|
-
import { attachVgd } from './chunk-
|
|
42
|
+
import { attachVgd } from './chunk-GRMZU24V.js';
|
|
42
43
|
import { pathExists as pathExists$1, parseExcludePatterns } from './chunk-PVNALGTG.js';
|
|
43
44
|
import { ensureDir, pathExists, readJsonFile, writeTextFile, writeJsonFile } from './chunk-CRAMOEBE.js';
|
|
44
45
|
import './chunk-5IQBIXHS.js';
|
|
@@ -47,27 +48,27 @@ import { publishGraphToVgd } from './chunk-A3WWRW7U.js';
|
|
|
47
48
|
import { isRelevantChange } from './chunk-DBX3DL27.js';
|
|
48
49
|
import { inventory, enrichOnline, ECOSYSTEMS } from './chunk-6BEBJCK4.js';
|
|
49
50
|
import { resolveOne } from './chunk-J7LKEB2R.js';
|
|
50
|
-
import { queryGraphSemantic, queryGraph, indexFor, impactOf } from './chunk-
|
|
51
|
-
import { loadGraph, loadGraphPreferIndex, SCHEMA_VERSION } from './chunk-
|
|
51
|
+
import { queryGraphSemantic, queryGraph, indexFor, impactOf } from './chunk-LUJ4H4RJ.js';
|
|
52
|
+
import { loadGraph, loadGraphPreferIndex, SCHEMA_VERSION } from './chunk-5BFA532E.js';
|
|
52
53
|
import './chunk-VHRSG6CF.js';
|
|
53
54
|
import './chunk-6H2QV5DR.js';
|
|
54
55
|
import { discover, isSkippedDirName } from './chunk-RTURQXQL.js';
|
|
55
|
-
import { resolvedGrammarFiles, TOOLCHAIN_GRAMMARS, resolveToolchainGrammar, grammarSetVersion, fileRolesFromParseCache } from './chunk-
|
|
56
|
+
import { resolvedGrammarFiles, TOOLCHAIN_GRAMMARS, resolveToolchainGrammar, grammarSetVersion, fileRolesFromParseCache } from './chunk-L3YEEJ6U.js';
|
|
56
57
|
import './chunk-T7RSQ5WD.js';
|
|
57
58
|
import './chunk-6WRG7VDO.js';
|
|
58
|
-
import { embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, unavailableMessage, countPending, modelCacheInfo, embeddingsPath, clearModelCache, withTimeout } from './chunk-
|
|
59
|
-
import { resetRelevanceProviderCache, loadRelevanceProvider,
|
|
59
|
+
import { embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, unavailableMessage, countPending, modelCacheInfo, embeddingsPath, clearModelCache, withTimeout } from './chunk-B5X246UH.js';
|
|
60
|
+
import { resetRelevanceProviderCache, loadRelevanceProvider, resolveGraphPath, loadTopicTags, rankQuestion, renderReport, loadGraphFileWithSnapshot, writeArtifacts, vibgrateDir, mapFileExists, ensureVibgrateGitignore } from './chunk-FVBN4E5C.js';
|
|
60
61
|
import { cacheDir } from './chunk-MVPRPSXU.js';
|
|
61
62
|
import { serializeGraph, stableStringify, parseGraph } from './chunk-O3LABX6I.js';
|
|
62
|
-
import { VERSION } from './chunk-
|
|
63
|
+
import { VERSION } from './chunk-KFLNWYZG.js';
|
|
63
64
|
import './chunk-XP6UUCZZ.js';
|
|
64
65
|
import { canonicalize, hashString } from './chunk-JFGYT6BI.js';
|
|
65
66
|
import './chunk-XQNKCA2J.js';
|
|
66
67
|
import { __toCommonJS } from './chunk-Z6ZWNWWR.js';
|
|
67
|
-
import * as
|
|
68
|
-
import
|
|
69
|
-
import * as
|
|
70
|
-
import
|
|
68
|
+
import * as fs12 from 'fs';
|
|
69
|
+
import fs12__default, { realpathSync } from 'fs';
|
|
70
|
+
import * as path45 from 'path';
|
|
71
|
+
import path45__default from 'path';
|
|
71
72
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
72
73
|
import { Command, CommanderError, Option } from 'commander';
|
|
73
74
|
import { execSync, spawn, spawnSync, execFileSync } from 'child_process';
|
|
@@ -75,11 +76,10 @@ import * as os from 'os';
|
|
|
75
76
|
import * as semver3 from 'semver';
|
|
76
77
|
import semver3__default from 'semver';
|
|
77
78
|
import * as readline from 'readline';
|
|
78
|
-
import * as zlib from 'zlib';
|
|
79
79
|
import * as crypto3 from 'crypto';
|
|
80
|
-
import { randomUUID
|
|
80
|
+
import { randomUUID } from 'crypto';
|
|
81
81
|
import chalk7 from 'chalk';
|
|
82
|
-
import * as
|
|
82
|
+
import * as fs26 from 'fs/promises';
|
|
83
83
|
import { parse, stringify } from 'yaml';
|
|
84
84
|
|
|
85
85
|
init_cli_invocation();
|
|
@@ -90,10 +90,10 @@ function registerStatus(program) {
|
|
|
90
90
|
applyGlobalOptions(cmd);
|
|
91
91
|
}
|
|
92
92
|
async function runStatus(global) {
|
|
93
|
-
const root3 =
|
|
93
|
+
const root3 = path45.resolve(global.cwd ?? ".");
|
|
94
94
|
const graphPath = resolveGraphPath(root3, global.graph);
|
|
95
95
|
const graph = loadGraph(root3, graphPath);
|
|
96
|
-
const hasCache =
|
|
96
|
+
const hasCache = fs12.existsSync(path45.join(cacheDir(root3), "parse-cache.json"));
|
|
97
97
|
let stale = null;
|
|
98
98
|
let staleExact = false;
|
|
99
99
|
if (graph) {
|
|
@@ -113,8 +113,8 @@ async function runStatus(global) {
|
|
|
113
113
|
}
|
|
114
114
|
if (global.json) {
|
|
115
115
|
json({
|
|
116
|
-
root:
|
|
117
|
-
graphPath:
|
|
116
|
+
root: path45.relative(process.cwd(), root3) || ".",
|
|
117
|
+
graphPath: path45.relative(root3, graphPath),
|
|
118
118
|
built: graph !== null,
|
|
119
119
|
generatedAt: graph?.generatedAt ?? null,
|
|
120
120
|
counts: graph?.meta.counts ?? null,
|
|
@@ -129,11 +129,11 @@ async function runStatus(global) {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
if (!graph) {
|
|
132
|
-
info(`${c.cyan("vg")} \xB7 no map yet at ${c.dim(
|
|
132
|
+
info(`${c.cyan("vg")} \xB7 no map yet at ${c.dim(path45.relative(root3, graphPath))}`);
|
|
133
133
|
info(` run ${c.bold("vg")} to build one`);
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
info(`${c.cyan("vg")} \xB7 ${
|
|
136
|
+
info(`${c.cyan("vg")} \xB7 ${path45.relative(root3, graphPath)}`);
|
|
137
137
|
info(` generated ${graph.generatedAt}`);
|
|
138
138
|
info(
|
|
139
139
|
` nodes ${c.bold(String(graph.meta.counts.nodes))} edges ${c.bold(
|
|
@@ -187,8 +187,9 @@ function registerAsk(program) {
|
|
|
187
187
|
let result;
|
|
188
188
|
let mode = "lexical";
|
|
189
189
|
let note = "";
|
|
190
|
-
|
|
191
|
-
const topicTags =
|
|
190
|
+
if (!global.local) await ensureRelevanceModule();
|
|
191
|
+
const topicTags = await loadTopicTags(graph, root3, resolveGraphPath(root3, global.graph));
|
|
192
|
+
const modRank = await rankQuestion(graph, q, { limit: 48, topicTags });
|
|
192
193
|
try {
|
|
193
194
|
if (wantSemantic) {
|
|
194
195
|
live?.set("asking the daemon\u2026");
|
|
@@ -206,8 +207,7 @@ function registerAsk(program) {
|
|
|
206
207
|
result = await queryGraphSemantic(graph, q, {
|
|
207
208
|
budget,
|
|
208
209
|
semanticRanked: ranked.ranked,
|
|
209
|
-
|
|
210
|
-
topicTags
|
|
210
|
+
ranked: modRank
|
|
211
211
|
});
|
|
212
212
|
mode = `semantic (vgd${ranked.model ? `, ${ranked.model}` : ""})`;
|
|
213
213
|
activity.add("answer", "ok", "answered from the daemon index \u2014 no local model load");
|
|
@@ -230,18 +230,18 @@ function registerAsk(program) {
|
|
|
230
230
|
const bar = !global.json ? new ProgressBar(c.dim("embedding")) : void 0;
|
|
231
231
|
const vectors = await getNodeEmbeddings(graph, embedder, root3, bar ? (d, t) => bar.update(d, t) : void 0);
|
|
232
232
|
bar?.done();
|
|
233
|
-
result = await queryGraphSemantic(graph, q, { budget, embedder, nodeVectors: vectors,
|
|
233
|
+
result = await queryGraphSemantic(graph, q, { budget, embedder, nodeVectors: vectors, ranked: modRank });
|
|
234
234
|
mode = `semantic (${embedder.id})`;
|
|
235
235
|
activity.add("answer", "ok", `answered in this process \xB7 ${embedder.id} \xB7 ${vectors.size} vector(s)`);
|
|
236
236
|
} else {
|
|
237
|
-
result = queryGraph(graph, q, { budget,
|
|
237
|
+
result = queryGraph(graph, q, { budget, ranked: modRank });
|
|
238
238
|
note = reason ? unavailableMessage(reason) : "semantic unavailable; used lexical";
|
|
239
239
|
if (detail) note += ` (${detail})`;
|
|
240
240
|
activity.add("answer", "warn", `lexical only \u2014 ${note}`);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
} else {
|
|
244
|
-
result = queryGraph(graph, q, { budget,
|
|
244
|
+
result = queryGraph(graph, q, { budget, ranked: modRank });
|
|
245
245
|
if (global.local) note = "semantic skipped under --local; used lexical";
|
|
246
246
|
activity.add("answer", "skip", global.local ? "lexical only (--local)" : "lexical only (--no-semantic)");
|
|
247
247
|
}
|
|
@@ -309,15 +309,15 @@ function crashedMessage(signal) {
|
|
|
309
309
|
return `semantic search is disabled: its native backend (onnxruntime-node, via the vendored fastembed path) crashed with ${signal} \u2014 using fast lexical search instead. This usually means the installed native binaries are broken (an interrupted install, or a platform without prebuilt CPU binaries). Reinstall to repair \u2014 ${envPrefix}npm install -g --allow-scripts=@vibgrate/cli,onnxruntime-node,msgpackr-extract @vibgrate/cli \u2014 or run with --local to stay lexical quietly.`;
|
|
310
310
|
}
|
|
311
311
|
function defaultCacheDir() {
|
|
312
|
-
const base = process.env.XDG_CACHE_HOME ||
|
|
313
|
-
return
|
|
312
|
+
const base = process.env.XDG_CACHE_HOME || path45.join(os.homedir(), ".cache");
|
|
313
|
+
return path45.join(base, "vibgrate", "models");
|
|
314
314
|
}
|
|
315
315
|
function verdictPath(dir) {
|
|
316
|
-
return
|
|
316
|
+
return path45.join(dir, `embed-health-${process.platform}-${process.arch}.json`);
|
|
317
317
|
}
|
|
318
318
|
function readVerdict(dir) {
|
|
319
319
|
try {
|
|
320
|
-
const raw = JSON.parse(
|
|
320
|
+
const raw = JSON.parse(fs12.readFileSync(verdictPath(dir), "utf8"));
|
|
321
321
|
if (raw?.status !== "ok" && raw?.status !== "crashed") return null;
|
|
322
322
|
if (raw.version !== VERSION) return null;
|
|
323
323
|
return raw;
|
|
@@ -327,18 +327,18 @@ function readVerdict(dir) {
|
|
|
327
327
|
}
|
|
328
328
|
function writeVerdict(dir, verdict) {
|
|
329
329
|
try {
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
331
|
+
fs12.writeFileSync(verdictPath(dir), JSON.stringify(verdict, null, 2) + "\n", "utf8");
|
|
332
332
|
} catch {
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
function probeModuleUrl(from = import.meta.url) {
|
|
336
|
-
const dir =
|
|
336
|
+
const dir = path45.dirname(fileURLToPath(from));
|
|
337
337
|
for (const name of ["embeddings.js", "index.js"]) {
|
|
338
|
-
const candidate =
|
|
339
|
-
if (
|
|
338
|
+
const candidate = path45.join(dir, name);
|
|
339
|
+
if (fs12.existsSync(candidate)) return pathToFileURL(candidate).href;
|
|
340
340
|
}
|
|
341
|
-
return pathToFileURL(
|
|
341
|
+
return pathToFileURL(path45.join(dir, "index.js")).href;
|
|
342
342
|
}
|
|
343
343
|
function defaultRunProbe(timeoutMs) {
|
|
344
344
|
const moduleUrl = probeModuleUrl();
|
|
@@ -416,7 +416,7 @@ async function embedderHealth(options = {}) {
|
|
|
416
416
|
}
|
|
417
417
|
function clearEmbedderHealth(cacheDir2) {
|
|
418
418
|
try {
|
|
419
|
-
|
|
419
|
+
fs12.unlinkSync(verdictPath(cacheDir2 ?? defaultCacheDir()));
|
|
420
420
|
} catch {
|
|
421
421
|
}
|
|
422
422
|
}
|
|
@@ -1091,12 +1091,12 @@ var PUBLISH_INTERVAL_MS = 2e3;
|
|
|
1091
1091
|
var KEEPALIVE_MS = 1e4;
|
|
1092
1092
|
var STALE_MS = 6e4;
|
|
1093
1093
|
function liveStatsDir(root3) {
|
|
1094
|
-
return
|
|
1094
|
+
return path45.join(cacheDir(root3), "serve-live");
|
|
1095
1095
|
}
|
|
1096
1096
|
function reapOtherVersionServers(dir, keepVersion, now = Date.now(), kill = (pid, signal) => process.kill(pid, signal), selfPid = process.pid) {
|
|
1097
1097
|
let entries;
|
|
1098
1098
|
try {
|
|
1099
|
-
entries =
|
|
1099
|
+
entries = fs12.readdirSync(dir);
|
|
1100
1100
|
} catch {
|
|
1101
1101
|
return [];
|
|
1102
1102
|
}
|
|
@@ -1105,7 +1105,7 @@ function reapOtherVersionServers(dir, keepVersion, now = Date.now(), kill = (pid
|
|
|
1105
1105
|
if (!/^serve-\d+\.json$/.test(name)) continue;
|
|
1106
1106
|
let parsed;
|
|
1107
1107
|
try {
|
|
1108
|
-
parsed = JSON.parse(
|
|
1108
|
+
parsed = JSON.parse(fs12.readFileSync(path45.join(dir, name), "utf8"));
|
|
1109
1109
|
} catch {
|
|
1110
1110
|
continue;
|
|
1111
1111
|
}
|
|
@@ -1127,7 +1127,7 @@ var LiveStatsBus = class {
|
|
|
1127
1127
|
this.dir = dir;
|
|
1128
1128
|
this.stats = stats;
|
|
1129
1129
|
this.pid = pid;
|
|
1130
|
-
this.file =
|
|
1130
|
+
this.file = path45.join(dir, `serve-${this.pid}.json`);
|
|
1131
1131
|
}
|
|
1132
1132
|
dir;
|
|
1133
1133
|
stats;
|
|
@@ -1159,10 +1159,10 @@ var LiveStatsBus = class {
|
|
|
1159
1159
|
this.lastWriteAt = now;
|
|
1160
1160
|
const body = { pid: this.pid, updatedAt: now, version: VERSION, snapshot: snap };
|
|
1161
1161
|
try {
|
|
1162
|
-
|
|
1162
|
+
fs12.mkdirSync(this.dir, { recursive: true });
|
|
1163
1163
|
const tmp = `${this.file}.tmp`;
|
|
1164
|
-
|
|
1165
|
-
|
|
1164
|
+
fs12.writeFileSync(tmp, JSON.stringify(body));
|
|
1165
|
+
fs12.renameSync(tmp, this.file);
|
|
1166
1166
|
} catch {
|
|
1167
1167
|
}
|
|
1168
1168
|
}
|
|
@@ -1173,24 +1173,24 @@ var LiveStatsBus = class {
|
|
|
1173
1173
|
siblings(now = Date.now()) {
|
|
1174
1174
|
let entries;
|
|
1175
1175
|
try {
|
|
1176
|
-
entries =
|
|
1176
|
+
entries = fs12.readdirSync(this.dir);
|
|
1177
1177
|
} catch {
|
|
1178
1178
|
return [];
|
|
1179
1179
|
}
|
|
1180
1180
|
const out2 = [];
|
|
1181
1181
|
for (const name of entries.sort()) {
|
|
1182
1182
|
if (!/^serve-\d+\.json$/.test(name)) continue;
|
|
1183
|
-
const file =
|
|
1183
|
+
const file = path45.join(this.dir, name);
|
|
1184
1184
|
let parsed;
|
|
1185
1185
|
try {
|
|
1186
|
-
parsed = JSON.parse(
|
|
1186
|
+
parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
1187
1187
|
} catch {
|
|
1188
1188
|
continue;
|
|
1189
1189
|
}
|
|
1190
1190
|
if (typeof parsed?.pid !== "number" || typeof parsed.updatedAt !== "number" || !parsed.snapshot?.totals) continue;
|
|
1191
1191
|
if (now - parsed.updatedAt > STALE_MS) {
|
|
1192
1192
|
try {
|
|
1193
|
-
|
|
1193
|
+
fs12.unlinkSync(file);
|
|
1194
1194
|
} catch {
|
|
1195
1195
|
}
|
|
1196
1196
|
continue;
|
|
@@ -1202,7 +1202,7 @@ var LiveStatsBus = class {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
unlinkOwn = () => {
|
|
1204
1204
|
try {
|
|
1205
|
-
|
|
1205
|
+
fs12.unlinkSync(this.file);
|
|
1206
1206
|
} catch {
|
|
1207
1207
|
}
|
|
1208
1208
|
};
|
|
@@ -1515,12 +1515,12 @@ var LedgerTail = class {
|
|
|
1515
1515
|
if (size === this.offset) return;
|
|
1516
1516
|
let chunk;
|
|
1517
1517
|
try {
|
|
1518
|
-
const fd =
|
|
1518
|
+
const fd = fs12.openSync(this.file, "r");
|
|
1519
1519
|
try {
|
|
1520
1520
|
chunk = Buffer.alloc(size - this.offset);
|
|
1521
|
-
|
|
1521
|
+
fs12.readSync(fd, chunk, 0, chunk.length, this.offset);
|
|
1522
1522
|
} finally {
|
|
1523
|
-
|
|
1523
|
+
fs12.closeSync(fd);
|
|
1524
1524
|
}
|
|
1525
1525
|
} catch {
|
|
1526
1526
|
return;
|
|
@@ -1533,7 +1533,7 @@ var LedgerTail = class {
|
|
|
1533
1533
|
}
|
|
1534
1534
|
sizeOf() {
|
|
1535
1535
|
try {
|
|
1536
|
-
return
|
|
1536
|
+
return fs12.statSync(this.file).size;
|
|
1537
1537
|
} catch {
|
|
1538
1538
|
return 0;
|
|
1539
1539
|
}
|
|
@@ -1826,10 +1826,10 @@ var Connection = class {
|
|
|
1826
1826
|
};
|
|
1827
1827
|
function projectDir(root3, projectPath) {
|
|
1828
1828
|
const rel = projectPath === "" || projectPath === "." ? "" : projectPath;
|
|
1829
|
-
return rel ?
|
|
1829
|
+
return rel ? path45.resolve(root3, rel) : path45.resolve(root3);
|
|
1830
1830
|
}
|
|
1831
1831
|
function projectForFile(root3, projects, filePath) {
|
|
1832
|
-
const dir =
|
|
1832
|
+
const dir = path45.dirname(path45.resolve(filePath));
|
|
1833
1833
|
for (const proj of projects) {
|
|
1834
1834
|
if (projectDir(root3, proj.path) === dir) return proj;
|
|
1835
1835
|
}
|
|
@@ -1838,7 +1838,7 @@ function projectForFile(root3, projects, filePath) {
|
|
|
1838
1838
|
let bestLen = -1;
|
|
1839
1839
|
for (const proj of projects) {
|
|
1840
1840
|
const projDir = projectDir(root3, proj.path);
|
|
1841
|
-
if ((dir === projDir || dir.startsWith(projDir +
|
|
1841
|
+
if ((dir === projDir || dir.startsWith(projDir + path45.sep)) && projDir.length > bestLen) {
|
|
1842
1842
|
best = proj;
|
|
1843
1843
|
bestLen = projDir.length;
|
|
1844
1844
|
}
|
|
@@ -1848,7 +1848,7 @@ function projectForFile(root3, projects, filePath) {
|
|
|
1848
1848
|
var MAX_ENTRIES = 1e3;
|
|
1849
1849
|
var KEEP_ENTRIES = 500;
|
|
1850
1850
|
function historyPath(root3) {
|
|
1851
|
-
return
|
|
1851
|
+
return path45.join(root3, ".vibgrate", "score-history.jsonl");
|
|
1852
1852
|
}
|
|
1853
1853
|
function parseLine(line) {
|
|
1854
1854
|
try {
|
|
@@ -1862,7 +1862,7 @@ function parseLine(line) {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
function readHistory(root3) {
|
|
1864
1864
|
try {
|
|
1865
|
-
return
|
|
1865
|
+
return fs12.readFileSync(historyPath(root3), "utf8").split("\n").filter((l) => l.trim()).map(parseLine).filter((e) => e !== null);
|
|
1866
1866
|
} catch {
|
|
1867
1867
|
return [];
|
|
1868
1868
|
}
|
|
@@ -1889,14 +1889,14 @@ function recordScore(root3, entry) {
|
|
|
1889
1889
|
}
|
|
1890
1890
|
}
|
|
1891
1891
|
const file = historyPath(root3);
|
|
1892
|
-
|
|
1892
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
1893
1893
|
ensureVibgrateGitignore(root3);
|
|
1894
|
-
|
|
1894
|
+
fs12.appendFileSync(file, `${JSON.stringify(entry)}
|
|
1895
1895
|
`);
|
|
1896
1896
|
const all = readHistory(root3);
|
|
1897
1897
|
if (all.length > MAX_ENTRIES) {
|
|
1898
1898
|
const kept = all.slice(-KEEP_ENTRIES);
|
|
1899
|
-
|
|
1899
|
+
fs12.writeFileSync(file, kept.map((e) => JSON.stringify(e)).join("\n") + "\n");
|
|
1900
1900
|
}
|
|
1901
1901
|
} catch {
|
|
1902
1902
|
}
|
|
@@ -1907,7 +1907,7 @@ function deltaFrom(prev, current) {
|
|
|
1907
1907
|
return current.score - prev.score;
|
|
1908
1908
|
}
|
|
1909
1909
|
function ignoreFilePath(root3) {
|
|
1910
|
-
return
|
|
1910
|
+
return path45.join(root3, ".vibgrate", "ignore.json");
|
|
1911
1911
|
}
|
|
1912
1912
|
function isActive(entry, now = Date.now()) {
|
|
1913
1913
|
if (!entry.until) return true;
|
|
@@ -1919,7 +1919,7 @@ function readIgnores(root3, now = Date.now()) {
|
|
|
1919
1919
|
const out2 = /* @__PURE__ */ new Map();
|
|
1920
1920
|
let raw;
|
|
1921
1921
|
try {
|
|
1922
|
-
raw =
|
|
1922
|
+
raw = fs12.readFileSync(ignoreFilePath(root3), "utf8");
|
|
1923
1923
|
} catch {
|
|
1924
1924
|
return out2;
|
|
1925
1925
|
}
|
|
@@ -1939,14 +1939,14 @@ function readIgnores(root3, now = Date.now()) {
|
|
|
1939
1939
|
return out2;
|
|
1940
1940
|
}
|
|
1941
1941
|
function inventoryPath(root3) {
|
|
1942
|
-
return
|
|
1942
|
+
return path45.join(root3, ".vibgrate", "inline-inventory.json");
|
|
1943
1943
|
}
|
|
1944
1944
|
function inventoryKey(projectPath, pkg) {
|
|
1945
1945
|
return `${projectPath}::${pkg}`;
|
|
1946
1946
|
}
|
|
1947
1947
|
function readInventory(root3) {
|
|
1948
1948
|
try {
|
|
1949
|
-
const parsed = JSON.parse(
|
|
1949
|
+
const parsed = JSON.parse(fs12.readFileSync(inventoryPath(root3), "utf8"));
|
|
1950
1950
|
if (typeof parsed.ts === "string" && typeof parsed.methodology === "string" && Array.isArray(parsed.drifted) && parsed.drifted.every((d) => typeof d === "string")) {
|
|
1951
1951
|
return parsed;
|
|
1952
1952
|
}
|
|
@@ -1957,7 +1957,7 @@ function readInventory(root3) {
|
|
|
1957
1957
|
function recordInventory(root3, snap) {
|
|
1958
1958
|
try {
|
|
1959
1959
|
ensureVibgrateGitignore(root3);
|
|
1960
|
-
|
|
1960
|
+
fs12.writeFileSync(inventoryPath(root3), `${JSON.stringify(snap)}
|
|
1961
1961
|
`);
|
|
1962
1962
|
} catch {
|
|
1963
1963
|
}
|
|
@@ -2889,7 +2889,7 @@ var VibgrateLanguageServer = class {
|
|
|
2889
2889
|
* the workspace scan cache (billing / repo score stay on the official scan).
|
|
2890
2890
|
*/
|
|
2891
2891
|
async scanOpenManifest(uri, filePath) {
|
|
2892
|
-
const relDir =
|
|
2892
|
+
const relDir = path45.relative(this.opts.root, path45.dirname(path45.resolve(filePath)));
|
|
2893
2893
|
const key2 = relDir === "" ? "." : relDir;
|
|
2894
2894
|
if (this.openManifestScans.has(key2) || this.openManifestFailed.has(key2)) return;
|
|
2895
2895
|
if (key2 === "." || key2.startsWith("..")) return;
|
|
@@ -2909,7 +2909,7 @@ var VibgrateLanguageServer = class {
|
|
|
2909
2909
|
quiet: true,
|
|
2910
2910
|
vibgrateVersion: VERSION
|
|
2911
2911
|
};
|
|
2912
|
-
const sub = await runCoreScanSilently(
|
|
2912
|
+
const sub = await runCoreScanSilently(path45.dirname(filePath), scanOpts, advanced);
|
|
2913
2913
|
const proj = (sub.projects ?? []).find((p) => p.path === "." || p.path === "") ?? sub.projects?.[0];
|
|
2914
2914
|
if (!proj || !this.artifact) {
|
|
2915
2915
|
this.openManifestFailed.add(key2);
|
|
@@ -3217,10 +3217,10 @@ var VibgrateLanguageServer = class {
|
|
|
3217
3217
|
const ecosystem = osvEcosystem(proj.type);
|
|
3218
3218
|
if (!ecosystem) continue;
|
|
3219
3219
|
const relManifest = manifestRelativePath(proj);
|
|
3220
|
-
const absManifest =
|
|
3220
|
+
const absManifest = path45.resolve(this.opts.root, relManifest);
|
|
3221
3221
|
let text = null;
|
|
3222
3222
|
try {
|
|
3223
|
-
if (
|
|
3223
|
+
if (fs12.existsSync(absManifest)) text = fs12.readFileSync(absManifest, "utf8");
|
|
3224
3224
|
} catch {
|
|
3225
3225
|
text = null;
|
|
3226
3226
|
}
|
|
@@ -3410,7 +3410,7 @@ function pruneArtifactProjects(a) {
|
|
|
3410
3410
|
return { ...a, projects, findings };
|
|
3411
3411
|
}
|
|
3412
3412
|
function projectByPath(a, projectPath) {
|
|
3413
|
-
const norm = (p) =>
|
|
3413
|
+
const norm = (p) => path45.normalize((p === "" ? "." : p).replace(/\\/g, "/"));
|
|
3414
3414
|
const want = norm(projectPath);
|
|
3415
3415
|
for (const proj of a.projects ?? []) {
|
|
3416
3416
|
if (norm(proj.path) === want) return proj;
|
|
@@ -3452,7 +3452,7 @@ function projectForFile2(root3, a, filePath) {
|
|
|
3452
3452
|
return projectForFile(root3, a.projects ?? [], filePath);
|
|
3453
3453
|
}
|
|
3454
3454
|
function sameProject(location, projectPath) {
|
|
3455
|
-
return
|
|
3455
|
+
return path45.normalize(location) === path45.normalize(projectPath);
|
|
3456
3456
|
}
|
|
3457
3457
|
function hasReleaseDates(a) {
|
|
3458
3458
|
for (const proj of a.projects ?? []) {
|
|
@@ -3522,10 +3522,10 @@ function buildBreakdown(rootDir, projects) {
|
|
|
3522
3522
|
const relManifest = manifestRelativePath(p);
|
|
3523
3523
|
if (isPrunedWorkspacePath(p.path) || isPrunedWorkspacePath(relManifest)) continue;
|
|
3524
3524
|
const ecosystem = osvEcosystem(p.type);
|
|
3525
|
-
const absManifest =
|
|
3525
|
+
const absManifest = path45.resolve(rootDir, relManifest);
|
|
3526
3526
|
let text = null;
|
|
3527
3527
|
try {
|
|
3528
|
-
if (
|
|
3528
|
+
if (fs12.existsSync(absManifest)) text = fs12.readFileSync(absManifest, "utf8");
|
|
3529
3529
|
} catch {
|
|
3530
3530
|
text = null;
|
|
3531
3531
|
}
|
|
@@ -3590,34 +3590,34 @@ function buildBreakdown(rootDir, projects) {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
function manifestRelativePath(proj) {
|
|
3592
3592
|
const base = proj.path === "." || proj.path === "" ? "" : proj.path;
|
|
3593
|
-
const
|
|
3593
|
+
const join34 = (name) => base ? path45.join(base, name) : name;
|
|
3594
3594
|
switch (proj.type) {
|
|
3595
3595
|
case "node":
|
|
3596
3596
|
case "typescript":
|
|
3597
|
-
return
|
|
3597
|
+
return join34("package.json");
|
|
3598
3598
|
case "python":
|
|
3599
|
-
return
|
|
3599
|
+
return join34("pyproject.toml");
|
|
3600
3600
|
case "go":
|
|
3601
|
-
return
|
|
3601
|
+
return join34("go.mod");
|
|
3602
3602
|
case "rust":
|
|
3603
|
-
return
|
|
3603
|
+
return join34("Cargo.toml");
|
|
3604
3604
|
case "ruby":
|
|
3605
|
-
return
|
|
3605
|
+
return join34("Gemfile");
|
|
3606
3606
|
case "php":
|
|
3607
|
-
return
|
|
3607
|
+
return join34("composer.json");
|
|
3608
3608
|
case "java":
|
|
3609
3609
|
case "kotlin":
|
|
3610
3610
|
case "scala":
|
|
3611
3611
|
case "groovy":
|
|
3612
|
-
return
|
|
3612
|
+
return join34("pom.xml");
|
|
3613
3613
|
case "dotnet":
|
|
3614
|
-
return
|
|
3614
|
+
return join34(proj.name ? `${proj.name}.csproj` : "Directory.Build.props");
|
|
3615
3615
|
case "dart":
|
|
3616
|
-
return
|
|
3616
|
+
return join34("pubspec.yaml");
|
|
3617
3617
|
case "elixir":
|
|
3618
|
-
return
|
|
3618
|
+
return join34("mix.exs");
|
|
3619
3619
|
default:
|
|
3620
|
-
return
|
|
3620
|
+
return join34("package.json");
|
|
3621
3621
|
}
|
|
3622
3622
|
}
|
|
3623
3623
|
function lockfileRelativePath(rootDir, proj) {
|
|
@@ -3648,9 +3648,9 @@ function lockfileRelativePath(rootDir, proj) {
|
|
|
3648
3648
|
const dirsToTry = base ? [base, ""] : [""];
|
|
3649
3649
|
for (const dir of dirsToTry) {
|
|
3650
3650
|
for (const name of candidateNames) {
|
|
3651
|
-
const rel = dir ?
|
|
3651
|
+
const rel = dir ? path45.join(dir, name) : name;
|
|
3652
3652
|
try {
|
|
3653
|
-
if (
|
|
3653
|
+
if (fs12.existsSync(path45.join(rootDir, rel))) return rel;
|
|
3654
3654
|
} catch {
|
|
3655
3655
|
}
|
|
3656
3656
|
}
|
|
@@ -3721,10 +3721,10 @@ function lookupImportFiles(map, pkg) {
|
|
|
3721
3721
|
}
|
|
3722
3722
|
function firstPackageMentionLine(root3, relFile, pkg) {
|
|
3723
3723
|
try {
|
|
3724
|
-
const abs =
|
|
3725
|
-
const stat2 =
|
|
3724
|
+
const abs = path45.resolve(root3, relFile);
|
|
3725
|
+
const stat2 = fs12.statSync(abs);
|
|
3726
3726
|
if (!stat2.isFile() || stat2.size > 256 * 1024) return null;
|
|
3727
|
-
const text =
|
|
3727
|
+
const text = fs12.readFileSync(abs, "utf8");
|
|
3728
3728
|
const tokens = [pkg];
|
|
3729
3729
|
if (pkg.startsWith("@")) {
|
|
3730
3730
|
const parts = pkg.split("/");
|
|
@@ -3920,7 +3920,7 @@ function hoverMarkdown(dep, contribution, state) {
|
|
|
3920
3920
|
return lines.join("\n");
|
|
3921
3921
|
}
|
|
3922
3922
|
function startLanguageServer(opts) {
|
|
3923
|
-
if (!
|
|
3923
|
+
if (!fs12.existsSync(opts.root)) {
|
|
3924
3924
|
process.stderr.write(`vg lsp: root does not exist: ${opts.root}
|
|
3925
3925
|
`);
|
|
3926
3926
|
process.exit(1);
|
|
@@ -3970,12 +3970,12 @@ function hookCommand(vgBin) {
|
|
|
3970
3970
|
return `${vgBin} hook pre-tool-use`;
|
|
3971
3971
|
}
|
|
3972
3972
|
function installClaudeHooks(root3, vgBin = "vg") {
|
|
3973
|
-
const file =
|
|
3974
|
-
const rel =
|
|
3973
|
+
const file = path45.join(root3, ".claude", "settings.json");
|
|
3974
|
+
const rel = path45.join(".claude", "settings.json");
|
|
3975
3975
|
let settings = {};
|
|
3976
|
-
if (
|
|
3976
|
+
if (fs12.existsSync(file)) {
|
|
3977
3977
|
try {
|
|
3978
|
-
const parsed = JSON.parse(
|
|
3978
|
+
const parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
3979
3979
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
3980
3980
|
return { file: rel, status: "skipped", note: "settings.json is not a JSON object \u2014 left untouched" };
|
|
3981
3981
|
}
|
|
@@ -4012,12 +4012,12 @@ function installClaudeHooks(root3, vgBin = "vg") {
|
|
|
4012
4012
|
return { file: rel, status: "written" };
|
|
4013
4013
|
}
|
|
4014
4014
|
function uninstallClaudeHooks(root3) {
|
|
4015
|
-
const file =
|
|
4016
|
-
const rel =
|
|
4017
|
-
if (!
|
|
4015
|
+
const file = path45.join(root3, ".claude", "settings.json");
|
|
4016
|
+
const rel = path45.join(".claude", "settings.json");
|
|
4017
|
+
if (!fs12.existsSync(file)) return { file: rel, status: "unchanged" };
|
|
4018
4018
|
let settings;
|
|
4019
4019
|
try {
|
|
4020
|
-
settings = JSON.parse(
|
|
4020
|
+
settings = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
4021
4021
|
} catch {
|
|
4022
4022
|
return { file: rel, status: "skipped", note: "settings.json is not parseable JSON \u2014 left untouched" };
|
|
4023
4023
|
}
|
|
@@ -4039,8 +4039,8 @@ function uninstallClaudeHooks(root3) {
|
|
|
4039
4039
|
return { file: rel, status: "written" };
|
|
4040
4040
|
}
|
|
4041
4041
|
function writeSettings(file, settings) {
|
|
4042
|
-
|
|
4043
|
-
|
|
4042
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
4043
|
+
fs12.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
4044
4044
|
`);
|
|
4045
4045
|
}
|
|
4046
4046
|
|
|
@@ -4154,189 +4154,24 @@ function resolve4(id) {
|
|
|
4154
4154
|
}
|
|
4155
4155
|
return a;
|
|
4156
4156
|
}
|
|
4157
|
-
var DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
4158
|
-
function registryBase(opts) {
|
|
4159
|
-
return (process.env.VIBGRATE_MODULE_REGISTRY || opts.registry || DEFAULT_REGISTRY).replace(/\/+$/, "");
|
|
4160
|
-
}
|
|
4161
|
-
function modulesBaseDir() {
|
|
4162
|
-
const base = process.env.XDG_CACHE_HOME || path46.join(os.homedir(), ".cache");
|
|
4163
|
-
return path46.join(base, "vibgrate", "modules");
|
|
4164
|
-
}
|
|
4165
|
-
function stateFile() {
|
|
4166
|
-
return path46.join(modulesBaseDir(), "consent.json");
|
|
4167
|
-
}
|
|
4168
|
-
function readConsent() {
|
|
4169
|
-
try {
|
|
4170
|
-
return JSON.parse(fs13.readFileSync(stateFile(), "utf8"));
|
|
4171
|
-
} catch {
|
|
4172
|
-
return {};
|
|
4173
|
-
}
|
|
4174
|
-
}
|
|
4175
|
-
function writeConsent(state) {
|
|
4176
|
-
try {
|
|
4177
|
-
fs13.mkdirSync(path46.dirname(stateFile()), { recursive: true });
|
|
4178
|
-
fs13.writeFileSync(stateFile(), JSON.stringify(state));
|
|
4179
|
-
} catch {
|
|
4180
|
-
}
|
|
4181
|
-
}
|
|
4182
|
-
function kernelDisabled() {
|
|
4183
|
-
const v = process.env.VIBGRATE_NO_KERNEL;
|
|
4184
|
-
return v === "1" || v === "true";
|
|
4185
|
-
}
|
|
4186
|
-
function moduleInstalledAt(dir) {
|
|
4187
|
-
try {
|
|
4188
|
-
const meta = JSON.parse(fs13.readFileSync(path46.join(dir, ".module.json"), "utf8"));
|
|
4189
|
-
if (fs13.existsSync(path46.join(dir, "index.js"))) {
|
|
4190
|
-
return { installed: true, version: meta.version };
|
|
4191
|
-
}
|
|
4192
|
-
} catch {
|
|
4193
|
-
}
|
|
4194
|
-
return { installed: false };
|
|
4195
|
-
}
|
|
4196
|
-
function verifyIntegrity(buf, integrity, shasum) {
|
|
4197
|
-
if (integrity) {
|
|
4198
|
-
const [algo, expected] = integrity.split("-", 2);
|
|
4199
|
-
if (!algo || !expected) throw new Error("malformed integrity metadata");
|
|
4200
|
-
const actual = createHash(algo).update(buf).digest("base64");
|
|
4201
|
-
if (actual !== expected) throw new Error(`integrity mismatch (${algo})`);
|
|
4202
|
-
return;
|
|
4203
|
-
}
|
|
4204
|
-
if (shasum) {
|
|
4205
|
-
const actual = createHash("sha1").update(buf).digest("hex");
|
|
4206
|
-
if (actual !== shasum) throw new Error("integrity mismatch (shasum)");
|
|
4207
|
-
return;
|
|
4208
|
-
}
|
|
4209
|
-
throw new Error("registry provided no integrity metadata");
|
|
4210
|
-
}
|
|
4211
|
-
function untar(data) {
|
|
4212
|
-
const out2 = [];
|
|
4213
|
-
let offset = 0;
|
|
4214
|
-
let pendingName = null;
|
|
4215
|
-
while (offset + 512 <= data.length) {
|
|
4216
|
-
const block = data.subarray(offset, offset + 512);
|
|
4217
|
-
offset += 512;
|
|
4218
|
-
if (block.every((b) => b === 0)) continue;
|
|
4219
|
-
const rawName = block.subarray(0, 100).toString("utf8").replace(/\0.*$/, "");
|
|
4220
|
-
const size = parseInt(block.subarray(124, 136).toString("utf8").replace(/\0.*$/, "").trim() || "0", 8);
|
|
4221
|
-
const type = String.fromCharCode(block[156]);
|
|
4222
|
-
const prefix = block.subarray(345, 500).toString("utf8").replace(/\0.*$/, "");
|
|
4223
|
-
const body = data.subarray(offset, offset + size);
|
|
4224
|
-
offset += Math.ceil(size / 512) * 512;
|
|
4225
|
-
if (type === "L") {
|
|
4226
|
-
pendingName = body.toString("utf8").replace(/\0.*$/, "");
|
|
4227
|
-
continue;
|
|
4228
|
-
}
|
|
4229
|
-
if (type === "x" || type === "g") {
|
|
4230
|
-
const m = /(?:^|\n)\d+ path=([^\n]+)\n/.exec(body.toString("utf8"));
|
|
4231
|
-
if (m) pendingName = m[1];
|
|
4232
|
-
continue;
|
|
4233
|
-
}
|
|
4234
|
-
if (type !== "0" && type !== "\0") continue;
|
|
4235
|
-
const name = pendingName ?? (prefix ? `${prefix}/${rawName}` : rawName);
|
|
4236
|
-
pendingName = null;
|
|
4237
|
-
if (name.split("/").includes("..") || path46.isAbsolute(name)) {
|
|
4238
|
-
throw new Error(`unsafe path in tarball: ${name}`);
|
|
4239
|
-
}
|
|
4240
|
-
out2.push({ name, body: Buffer.from(body) });
|
|
4241
|
-
}
|
|
4242
|
-
return out2;
|
|
4243
|
-
}
|
|
4244
|
-
async function installModule(mod, opts = {}) {
|
|
4245
|
-
if (kernelDisabled()) return { status: "disabled", detail: "VIBGRATE_NO_KERNEL is set" };
|
|
4246
|
-
const existing = moduleInstalledAt(mod.dir());
|
|
4247
|
-
if (existing.installed && !opts.force) return { status: "already-installed", version: existing.version };
|
|
4248
|
-
const doFetch = opts.fetchImpl ?? fetch;
|
|
4249
|
-
const base = registryBase(opts);
|
|
4250
|
-
try {
|
|
4251
|
-
const metaRes = await doFetch(`${base}/${mod.npmName.replace("/", "%2f")}`);
|
|
4252
|
-
if (!metaRes.ok) return { status: "unavailable", detail: `registry ${metaRes.status}` };
|
|
4253
|
-
const meta = await metaRes.json();
|
|
4254
|
-
const version = meta["dist-tags"]?.latest;
|
|
4255
|
-
const dist = version ? meta.versions?.[version]?.dist : void 0;
|
|
4256
|
-
if (!version || !dist?.tarball) return { status: "unavailable", detail: "no published version" };
|
|
4257
|
-
const tarRes = await doFetch(dist.tarball);
|
|
4258
|
-
if (!tarRes.ok) return { status: "unavailable", detail: `tarball ${tarRes.status}` };
|
|
4259
|
-
const gz = Buffer.from(await tarRes.arrayBuffer());
|
|
4260
|
-
verifyIntegrity(gz, dist.integrity, dist.shasum);
|
|
4261
|
-
const entries = untar(zlib.gunzipSync(gz));
|
|
4262
|
-
const dir = mod.dir();
|
|
4263
|
-
fs13.rmSync(dir, { recursive: true, force: true });
|
|
4264
|
-
fs13.mkdirSync(dir, { recursive: true });
|
|
4265
|
-
let wrote = 0;
|
|
4266
|
-
for (const e of entries) {
|
|
4267
|
-
let rel = null;
|
|
4268
|
-
if (e.name.startsWith("package/dist/")) rel = e.name.slice("package/dist/".length);
|
|
4269
|
-
else if (e.name === "package/LICENSE" || e.name === "package/README.md") rel = e.name.slice("package/".length);
|
|
4270
|
-
if (!rel) continue;
|
|
4271
|
-
const target = path46.join(dir, rel);
|
|
4272
|
-
if (!target.startsWith(dir + path46.sep) && target !== dir) throw new Error(`unsafe extract path: ${rel}`);
|
|
4273
|
-
fs13.mkdirSync(path46.dirname(target), { recursive: true });
|
|
4274
|
-
fs13.writeFileSync(target, e.body);
|
|
4275
|
-
wrote += 1;
|
|
4276
|
-
}
|
|
4277
|
-
if (!wrote || !fs13.existsSync(path46.join(dir, "index.js"))) {
|
|
4278
|
-
fs13.rmSync(dir, { recursive: true, force: true });
|
|
4279
|
-
return { status: "unavailable", detail: "package layout not recognized (no dist/index.js)" };
|
|
4280
|
-
}
|
|
4281
|
-
fs13.writeFileSync(path46.join(dir, ".module.json"), JSON.stringify({ name: mod.npmName, version }));
|
|
4282
|
-
mod.onChanged?.();
|
|
4283
|
-
return { status: "installed", version };
|
|
4284
|
-
} catch (e) {
|
|
4285
|
-
return { status: "unavailable", detail: String(e.message ?? e).slice(0, 200) };
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4288
|
-
function removeModule(mod) {
|
|
4289
|
-
fs13.rmSync(mod.dir(), { recursive: true, force: true });
|
|
4290
|
-
mod.onChanged?.();
|
|
4291
|
-
}
|
|
4292
|
-
|
|
4293
|
-
// src/install/relevance-module.ts
|
|
4294
|
-
var RELEVANCE_MODULE_NAME = "@vibgrate/relevance";
|
|
4295
|
-
var RELEVANCE_MODULE = {
|
|
4296
|
-
id: "relevance",
|
|
4297
|
-
npmName: RELEVANCE_MODULE_NAME,
|
|
4298
|
-
dir: relevanceModuleDir,
|
|
4299
|
-
onChanged: resetRelevanceProviderCache
|
|
4300
|
-
};
|
|
4301
|
-
function moduleInstalled() {
|
|
4302
|
-
return moduleInstalledAt(relevanceModuleDir());
|
|
4303
|
-
}
|
|
4304
|
-
var DISCLOSURE = "vg can install the optional Vibgrate relevance module (proprietary license, runs fully locally, improves how questions find the code they mean). Disable any time with VIBGRATE_NO_KERNEL=1.";
|
|
4305
|
-
async function installRelevanceModule(opts = {}) {
|
|
4306
|
-
return installModule(RELEVANCE_MODULE, opts);
|
|
4307
|
-
}
|
|
4308
|
-
function removeRelevanceModule() {
|
|
4309
|
-
removeModule(RELEVANCE_MODULE);
|
|
4310
|
-
}
|
|
4311
|
-
async function ensureRelevanceModule(io = {}) {
|
|
4312
|
-
try {
|
|
4313
|
-
if (kernelDisabled()) return { status: "disabled" };
|
|
4314
|
-
const existing = moduleInstalled();
|
|
4315
|
-
if (existing.installed) return { status: "already-installed", version: existing.version };
|
|
4316
|
-
if (readConsent().relevance === "denied") return { status: "declined" };
|
|
4317
|
-
return await installRelevanceModule({ fetchImpl: io.fetchImpl });
|
|
4318
|
-
} catch {
|
|
4319
|
-
return { status: "unavailable", detail: "auto-install failed" };
|
|
4320
|
-
}
|
|
4321
|
-
}
|
|
4322
4157
|
function disabled() {
|
|
4323
4158
|
const v = process.env.VIBGRATE_NO_KERNEL;
|
|
4324
4159
|
return v === "1" || v === "true";
|
|
4325
4160
|
}
|
|
4326
4161
|
function hcsModuleDir() {
|
|
4327
|
-
return
|
|
4162
|
+
return path45.join(modulesBaseDir(), "hcs");
|
|
4328
4163
|
}
|
|
4329
4164
|
function candidatePaths() {
|
|
4330
4165
|
const custom = process.env.VIBGRATE_HCS_PATH;
|
|
4331
4166
|
if (custom) {
|
|
4332
|
-
const p =
|
|
4167
|
+
const p = path45.resolve(custom);
|
|
4333
4168
|
try {
|
|
4334
|
-
if (
|
|
4169
|
+
if (fs12.statSync(p).isDirectory()) return [path45.join(p, "index.js")];
|
|
4335
4170
|
} catch {
|
|
4336
4171
|
}
|
|
4337
4172
|
return [p];
|
|
4338
4173
|
}
|
|
4339
|
-
return [
|
|
4174
|
+
return [path45.join(hcsModuleDir(), "index.js")];
|
|
4340
4175
|
}
|
|
4341
4176
|
var cached;
|
|
4342
4177
|
function resetHcsEngineCache() {
|
|
@@ -4347,7 +4182,7 @@ async function loadHcsEngine() {
|
|
|
4347
4182
|
cached = null;
|
|
4348
4183
|
if (disabled()) return cached;
|
|
4349
4184
|
for (const p of candidatePaths()) {
|
|
4350
|
-
if (!
|
|
4185
|
+
if (!fs12.existsSync(p)) continue;
|
|
4351
4186
|
try {
|
|
4352
4187
|
const mod = await import(pathToFileURL(p).href);
|
|
4353
4188
|
const engine = await mod.createHcsEngine?.();
|
|
@@ -4514,7 +4349,7 @@ function hookContext(payloadText, root3, graphOverride) {
|
|
|
4514
4349
|
let graph;
|
|
4515
4350
|
try {
|
|
4516
4351
|
const preferred = loadGraphPreferIndex(root3, graphPath);
|
|
4517
|
-
graph = preferred ? preferred.graph : parseGraph(
|
|
4352
|
+
graph = preferred ? preferred.graph : parseGraph(fs12.readFileSync(graphPath, "utf8"));
|
|
4518
4353
|
} catch {
|
|
4519
4354
|
return null;
|
|
4520
4355
|
}
|
|
@@ -4536,7 +4371,7 @@ function registerHook(program) {
|
|
|
4536
4371
|
const global = readGlobal(this);
|
|
4537
4372
|
const root3 = rootOf(global);
|
|
4538
4373
|
try {
|
|
4539
|
-
const stdin =
|
|
4374
|
+
const stdin = fs12.readFileSync(0, "utf8");
|
|
4540
4375
|
const context = hookContext(stdin, root3, global.graph);
|
|
4541
4376
|
if (context) {
|
|
4542
4377
|
process.stdout.write(
|
|
@@ -4556,8 +4391,8 @@ function registerShare(program) {
|
|
|
4556
4391
|
const cmd = program.command("share").description("make the map committable + auto-updating for your team (git)").option("--undo", "reverse what `vg share` installed").option("--reports", "also commit graph.html / GRAPH_REPORT.md (default: gitignored)").action(function(opts) {
|
|
4557
4392
|
const global = readGlobal(this);
|
|
4558
4393
|
const root3 = rootOf(global);
|
|
4559
|
-
const gitDir =
|
|
4560
|
-
if (!
|
|
4394
|
+
const gitDir = path45.join(root3, ".git");
|
|
4395
|
+
if (!fs12.existsSync(gitDir)) {
|
|
4561
4396
|
throw new CliError("not a git repository \u2014 run `vg share` inside a git repo", ExitCode.USAGE_ERROR);
|
|
4562
4397
|
}
|
|
4563
4398
|
if (opts.undo) {
|
|
@@ -4578,23 +4413,23 @@ function registerShare(program) {
|
|
|
4578
4413
|
applyGlobalOptions(cmd);
|
|
4579
4414
|
}
|
|
4580
4415
|
function writeVibgrateGitignore(root3, reports) {
|
|
4581
|
-
const dir =
|
|
4582
|
-
|
|
4416
|
+
const dir = path45.join(root3, ".vibgrate");
|
|
4417
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
4583
4418
|
const lines = ["# Managed by `vg share` \u2014 keep graph.json committed, ignore the rest", "cache/", "facts.jsonl", "graph.snap"];
|
|
4584
4419
|
if (!reports) lines.push("graph.html", "GRAPH_REPORT.md");
|
|
4585
|
-
|
|
4420
|
+
fs12.writeFileSync(path45.join(dir, ".gitignore"), `${lines.join("\n")}
|
|
4586
4421
|
`);
|
|
4587
4422
|
}
|
|
4588
4423
|
function writeGitAttributes(root3) {
|
|
4589
|
-
const file =
|
|
4424
|
+
const file = path45.join(root3, ".gitattributes");
|
|
4590
4425
|
const line = ".vibgrate/graph.json merge=vg";
|
|
4591
|
-
let content =
|
|
4426
|
+
let content = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : "";
|
|
4592
4427
|
if (!content.split("\n").some((l) => l.trim() === line)) {
|
|
4593
4428
|
content = content.length ? `${content.replace(/\s*$/, "")}
|
|
4594
4429
|
${line}
|
|
4595
4430
|
` : `${line}
|
|
4596
4431
|
`;
|
|
4597
|
-
|
|
4432
|
+
fs12.writeFileSync(file, content);
|
|
4598
4433
|
}
|
|
4599
4434
|
}
|
|
4600
4435
|
function configureMergeDriver(root3) {
|
|
@@ -4603,8 +4438,8 @@ function configureMergeDriver(root3) {
|
|
|
4603
4438
|
}
|
|
4604
4439
|
function installPreCommitHook(root3) {
|
|
4605
4440
|
const hooksDir = hookDir(root3);
|
|
4606
|
-
|
|
4607
|
-
const file =
|
|
4441
|
+
fs12.mkdirSync(hooksDir, { recursive: true });
|
|
4442
|
+
const file = path45.join(hooksDir, "pre-commit");
|
|
4608
4443
|
const block = [
|
|
4609
4444
|
HOOK_BEGIN,
|
|
4610
4445
|
"if command -v vg >/dev/null 2>&1; then",
|
|
@@ -4613,7 +4448,7 @@ function installPreCommitHook(root3) {
|
|
|
4613
4448
|
"fi",
|
|
4614
4449
|
HOOK_END
|
|
4615
4450
|
].join("\n");
|
|
4616
|
-
let content =
|
|
4451
|
+
let content = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : "#!/bin/sh\n";
|
|
4617
4452
|
const re = new RegExp(`${escapeRe(HOOK_BEGIN)}[\\s\\S]*?${escapeRe(HOOK_END)}`);
|
|
4618
4453
|
if (re.test(content)) content = content.replace(re, block);
|
|
4619
4454
|
else content = `${content.replace(/\s*$/, "")}
|
|
@@ -4622,21 +4457,21 @@ ${block}
|
|
|
4622
4457
|
`;
|
|
4623
4458
|
if (!content.startsWith("#!")) content = `#!/bin/sh
|
|
4624
4459
|
${content}`;
|
|
4625
|
-
|
|
4626
|
-
|
|
4460
|
+
fs12.writeFileSync(file, content);
|
|
4461
|
+
fs12.chmodSync(file, 493);
|
|
4627
4462
|
}
|
|
4628
4463
|
function undo(root3) {
|
|
4629
|
-
const hookFile =
|
|
4630
|
-
if (
|
|
4464
|
+
const hookFile = path45.join(hookDir(root3), "pre-commit");
|
|
4465
|
+
if (fs12.existsSync(hookFile)) {
|
|
4631
4466
|
const re = new RegExp(`\\n*${escapeRe(HOOK_BEGIN)}[\\s\\S]*?${escapeRe(HOOK_END)}\\n*`);
|
|
4632
|
-
const next2 =
|
|
4633
|
-
if (next2.trim() === "#!/bin/sh")
|
|
4634
|
-
else
|
|
4467
|
+
const next2 = fs12.readFileSync(hookFile, "utf8").replace(re, "\n");
|
|
4468
|
+
if (next2.trim() === "#!/bin/sh") fs12.rmSync(hookFile);
|
|
4469
|
+
else fs12.writeFileSync(hookFile, next2);
|
|
4635
4470
|
}
|
|
4636
|
-
const attr =
|
|
4637
|
-
if (
|
|
4638
|
-
const next2 =
|
|
4639
|
-
|
|
4471
|
+
const attr = path45.join(root3, ".gitattributes");
|
|
4472
|
+
if (fs12.existsSync(attr)) {
|
|
4473
|
+
const next2 = fs12.readFileSync(attr, "utf8").split("\n").filter((l) => l.trim() !== ".vibgrate/graph.json merge=vg").join("\n");
|
|
4474
|
+
fs12.writeFileSync(attr, next2);
|
|
4640
4475
|
}
|
|
4641
4476
|
try {
|
|
4642
4477
|
git(root3, ["config", "--remove-section", "merge.vg"]);
|
|
@@ -4646,10 +4481,10 @@ function undo(root3) {
|
|
|
4646
4481
|
function hookDir(root3) {
|
|
4647
4482
|
try {
|
|
4648
4483
|
const configured = git(root3, ["config", "--get", "core.hooksPath"]).trim();
|
|
4649
|
-
if (configured) return
|
|
4484
|
+
if (configured) return path45.resolve(root3, configured);
|
|
4650
4485
|
} catch {
|
|
4651
4486
|
}
|
|
4652
|
-
return
|
|
4487
|
+
return path45.join(root3, ".git", "hooks");
|
|
4653
4488
|
}
|
|
4654
4489
|
function git(root3, args) {
|
|
4655
4490
|
return execFileSync("git", args, { cwd: root3, encoding: "utf8" });
|
|
@@ -4663,9 +4498,9 @@ function registerWatch(program) {
|
|
|
4663
4498
|
const global = readGlobal(this);
|
|
4664
4499
|
const root3 = rootOf(global);
|
|
4665
4500
|
const debounceMs = Math.max(50, Number(opts.debounce) || DEFAULT_DEBOUNCE_MS);
|
|
4666
|
-
const watchRoots = (paths.length ? paths : ["."]).map((p) =>
|
|
4501
|
+
const watchRoots = (paths.length ? paths : ["."]).map((p) => path45.resolve(root3, p));
|
|
4667
4502
|
for (const w of watchRoots) {
|
|
4668
|
-
if (!
|
|
4503
|
+
if (!fs12.existsSync(w)) {
|
|
4669
4504
|
throw new CliError(`watch path not found: ${w}`, ExitCode.USAGE_ERROR);
|
|
4670
4505
|
}
|
|
4671
4506
|
}
|
|
@@ -4718,7 +4553,7 @@ function registerWatch(program) {
|
|
|
4718
4553
|
const watchers = [];
|
|
4719
4554
|
for (const w of watchRoots) {
|
|
4720
4555
|
try {
|
|
4721
|
-
const watcher =
|
|
4556
|
+
const watcher = fs12.watch(w, { recursive: true }, (_event, filename) => {
|
|
4722
4557
|
if (!filename) {
|
|
4723
4558
|
schedule("change");
|
|
4724
4559
|
return;
|
|
@@ -4731,7 +4566,7 @@ function registerWatch(program) {
|
|
|
4731
4566
|
throw new CliError(`cannot watch ${w}: ${err.message}`, ExitCode.ERROR);
|
|
4732
4567
|
}
|
|
4733
4568
|
}
|
|
4734
|
-
info(c.dim(`vg watch \xB7 watching ${watchRoots.map((p) =>
|
|
4569
|
+
info(c.dim(`vg watch \xB7 watching ${watchRoots.map((p) => path45.relative(root3, p) || ".").join(", ")} (debounce ${debounceMs}ms) \xB7 Ctrl+C to stop`));
|
|
4735
4570
|
await new Promise((resolve23) => {
|
|
4736
4571
|
const stop = () => {
|
|
4737
4572
|
for (const w of watchers) w.close();
|
|
@@ -5064,10 +4899,10 @@ function normalizeStandards(raw) {
|
|
|
5064
4899
|
}
|
|
5065
4900
|
function loadStandards(root3) {
|
|
5066
4901
|
for (const rel of STANDARDS_FILES) {
|
|
5067
|
-
const p =
|
|
4902
|
+
const p = path45__default.join(root3, rel);
|
|
5068
4903
|
let text;
|
|
5069
4904
|
try {
|
|
5070
|
-
text =
|
|
4905
|
+
text = fs12__default.readFileSync(p, "utf8");
|
|
5071
4906
|
} catch {
|
|
5072
4907
|
continue;
|
|
5073
4908
|
}
|
|
@@ -5785,8 +5620,8 @@ async function runHostBench(options = {}) {
|
|
|
5785
5620
|
}
|
|
5786
5621
|
async function runArmSimulate(input) {
|
|
5787
5622
|
const { arm, lib, modelPath, turns, trie, env, live } = input;
|
|
5788
|
-
const
|
|
5789
|
-
const session = await acquireHostSession(lib,
|
|
5623
|
+
const path47 = `${modelPath}#${arm.id}`;
|
|
5624
|
+
const session = await acquireHostSession(lib, path47);
|
|
5790
5625
|
const system = "You are a coding agent with a Task Capsule.";
|
|
5791
5626
|
const capsule = "function readConfig(): Config { return load(); }";
|
|
5792
5627
|
let last = null;
|
|
@@ -6319,6 +6154,9 @@ AssertionError: expected 5000`,
|
|
|
6319
6154
|
approve: async () => options.autoApprove !== false,
|
|
6320
6155
|
auto: true,
|
|
6321
6156
|
capsule: usedCapsule,
|
|
6157
|
+
// FCS / ZNS@1 measure the ranked Task Capsule. Tiny fixtures would
|
|
6158
|
+
// otherwise auto-select whole-repo paste and report usedCapsule=false.
|
|
6159
|
+
capsuleMode: usedCapsule ? "compile" : void 0,
|
|
6322
6160
|
verify: task.verifyCommand ? { command: task.verifyCommand, maxRounds: 2 } : void 0,
|
|
6323
6161
|
verifyLadder: usedCapsule,
|
|
6324
6162
|
overlay: usedCapsule,
|
|
@@ -6998,7 +6836,7 @@ function registerModels(program) {
|
|
|
6998
6836
|
);
|
|
6999
6837
|
}
|
|
7000
6838
|
} else {
|
|
7001
|
-
if (!target.path || !
|
|
6839
|
+
if (!target.path || !fs12.existsSync(target.path)) {
|
|
7002
6840
|
throw new CliError(
|
|
7003
6841
|
`model file not found at ${target.path || "(unknown path)"} \u2014 it may already be removed.`,
|
|
7004
6842
|
ExitCode.NOT_FOUND
|
|
@@ -7012,7 +6850,7 @@ function registerModels(program) {
|
|
|
7012
6850
|
}
|
|
7013
6851
|
if (!global.json) info(c.dim(` $ rm ${target.path}`));
|
|
7014
6852
|
try {
|
|
7015
|
-
|
|
6853
|
+
fs12.unlinkSync(target.path);
|
|
7016
6854
|
} catch (e) {
|
|
7017
6855
|
const msg = e instanceof Error ? e.message : String(e);
|
|
7018
6856
|
throw new CliError(`could not delete ${target.path}: ${msg}`, ExitCode.ERROR);
|
|
@@ -7150,9 +6988,9 @@ function registerModels(program) {
|
|
|
7150
6988
|
}
|
|
7151
6989
|
});
|
|
7152
6990
|
if (opts.out) {
|
|
7153
|
-
const outPath =
|
|
7154
|
-
|
|
7155
|
-
|
|
6991
|
+
const outPath = path45.resolve(opts.out);
|
|
6992
|
+
fs12.mkdirSync(path45.dirname(outPath), { recursive: true });
|
|
6993
|
+
fs12.writeFileSync(outPath, `${JSON.stringify(report, null, 2)}
|
|
7156
6994
|
`);
|
|
7157
6995
|
if (!global.json) info(c.dim(` wrote ${outPath}`));
|
|
7158
6996
|
}
|
|
@@ -7301,14 +7139,14 @@ function resolveUninstallTarget(name, runtimeOpt) {
|
|
|
7301
7139
|
}
|
|
7302
7140
|
return exact[0];
|
|
7303
7141
|
}
|
|
7304
|
-
const base =
|
|
7142
|
+
const base = path45.basename(wantLc);
|
|
7305
7143
|
const soft = fleet.filter((m) => {
|
|
7306
7144
|
const n = m.name.toLowerCase();
|
|
7307
|
-
return n === base || n.endsWith("/" + base) || n.endsWith(wantLc) ||
|
|
7145
|
+
return n === base || n.endsWith("/" + base) || n.endsWith(wantLc) || path45.basename(n) === base;
|
|
7308
7146
|
});
|
|
7309
7147
|
if (soft.length === 1) return soft[0];
|
|
7310
7148
|
if (soft.length > 1) {
|
|
7311
|
-
const baseHits = soft.filter((m) =>
|
|
7149
|
+
const baseHits = soft.filter((m) => path45.basename(m.name).toLowerCase() === base);
|
|
7312
7150
|
const pool = baseHits.length ? baseHits : soft;
|
|
7313
7151
|
const order = ["ollama", "gguf", "lm-studio"];
|
|
7314
7152
|
for (const rt of order) {
|
|
@@ -7346,11 +7184,11 @@ function printBackends(backends) {
|
|
|
7346
7184
|
}
|
|
7347
7185
|
}
|
|
7348
7186
|
function codeConfigPath(root3) {
|
|
7349
|
-
return
|
|
7187
|
+
return path45.join(root3, ".vibgrate", "code.json");
|
|
7350
7188
|
}
|
|
7351
7189
|
function loadCodeConfig(root3) {
|
|
7352
7190
|
try {
|
|
7353
|
-
const raw = JSON.parse(
|
|
7191
|
+
const raw = JSON.parse(fs12.readFileSync(codeConfigPath(root3), "utf8"));
|
|
7354
7192
|
return sanitize(raw);
|
|
7355
7193
|
} catch {
|
|
7356
7194
|
return {};
|
|
@@ -7417,7 +7255,7 @@ function contextBudgetFor(config, modelContextWindow) {
|
|
|
7417
7255
|
var MCP_CONFIG_FILES = [".cursor/mcp.json", ".vscode/mcp.json", ".mcp.json"];
|
|
7418
7256
|
function readMcpServersFile(file) {
|
|
7419
7257
|
try {
|
|
7420
|
-
const raw = JSON.parse(
|
|
7258
|
+
const raw = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
7421
7259
|
const map = raw.mcpServers ?? raw.servers;
|
|
7422
7260
|
return map && typeof map === "object" ? parseMcpServers(map) : {};
|
|
7423
7261
|
} catch {
|
|
@@ -7428,7 +7266,7 @@ function discoverMcpServers(root3, ownServers) {
|
|
|
7428
7266
|
const servers = {};
|
|
7429
7267
|
const sources = [];
|
|
7430
7268
|
for (const rel of MCP_CONFIG_FILES) {
|
|
7431
|
-
const found = readMcpServersFile(
|
|
7269
|
+
const found = readMcpServersFile(path45.join(root3, rel));
|
|
7432
7270
|
const names = Object.keys(found);
|
|
7433
7271
|
if (names.length) {
|
|
7434
7272
|
sources.push(rel);
|
|
@@ -7493,7 +7331,7 @@ function registerCode(program) {
|
|
|
7493
7331
|
if (opts.worktreeDiff || opts.worktreeApply || opts.worktreeRemove) {
|
|
7494
7332
|
const wt = await import('./worktree-session-D575IQWM.js');
|
|
7495
7333
|
const child = await import('child_process');
|
|
7496
|
-
const
|
|
7334
|
+
const os6 = await import('os');
|
|
7497
7335
|
const pathMod = await import('path');
|
|
7498
7336
|
const root4 = rootOf(global);
|
|
7499
7337
|
const gitRunner = (gitArgs, gitEnv) => {
|
|
@@ -7542,10 +7380,10 @@ function registerCode(program) {
|
|
|
7542
7380
|
return;
|
|
7543
7381
|
}
|
|
7544
7382
|
const patchFile = pathMod.join(
|
|
7545
|
-
|
|
7383
|
+
fs12.mkdtempSync(pathMod.join(os6.tmpdir(), "vg-wt-")),
|
|
7546
7384
|
"delta.patch"
|
|
7547
7385
|
);
|
|
7548
|
-
|
|
7386
|
+
fs12.writeFileSync(patchFile, diff2.patch);
|
|
7549
7387
|
const outcome = wt.applyWorktreePatch(gitRunner, root4, patchFile, diff2.files);
|
|
7550
7388
|
emitLine({ event: "worktree-applied", id: target.id, ...outcome });
|
|
7551
7389
|
if (!opts.streamJson && !global.json) {
|
|
@@ -7611,7 +7449,7 @@ function registerCode(program) {
|
|
|
7611
7449
|
try {
|
|
7612
7450
|
const { parseMode: parseMode2, resolveMode: resolveMode2, readOrchestratorState: readOrchestratorState2, activePin: activePin2 } = await import('./model-orchestrator-X3NE3Y2G.js');
|
|
7613
7451
|
const { gatherSystemMemory: gatherSystemMemory2 } = await import('./local-runtime-GA43KYS5.js');
|
|
7614
|
-
const { loadGraph: loadGraph2 } = await import('./load-
|
|
7452
|
+
const { loadGraph: loadGraph2 } = await import('./load-2FRH37JY.js');
|
|
7615
7453
|
const state = readOrchestratorState2();
|
|
7616
7454
|
const mode = parseMode2(modeFlag) ?? state.defaultMode ?? void 0;
|
|
7617
7455
|
const pin = mode ? activePin2(mode, state) : null;
|
|
@@ -7696,7 +7534,7 @@ function registerCode(program) {
|
|
|
7696
7534
|
if (!(process.stdin.isTTY && process.stdout.isTTY)) {
|
|
7697
7535
|
throw usageError('say what to change, e.g. `vg code "add a --timeout flag to the scan command"` (guided mode needs an interactive terminal)');
|
|
7698
7536
|
}
|
|
7699
|
-
const { runInteractive } = await import('./interactive-
|
|
7537
|
+
const { runInteractive } = await import('./interactive-K446F42I.js');
|
|
7700
7538
|
await runInteractive(
|
|
7701
7539
|
rootOf(global),
|
|
7702
7540
|
global,
|
|
@@ -7726,7 +7564,7 @@ function registerCode(program) {
|
|
|
7726
7564
|
}
|
|
7727
7565
|
if (!instruction && !stdinFirstTurn) throw usageError('say what to change, e.g. `vg code "add a --timeout flag to the scan command"`');
|
|
7728
7566
|
{
|
|
7729
|
-
const { ensureCodeMap } = await import('./ensure-map-
|
|
7567
|
+
const { ensureCodeMap } = await import('./ensure-map-MLI4XCRV.js');
|
|
7730
7568
|
const mapRoot = rootOf(global);
|
|
7731
7569
|
try {
|
|
7732
7570
|
await ensureCodeMap(mapRoot, global, {
|
|
@@ -7763,7 +7601,7 @@ function registerCode(program) {
|
|
|
7763
7601
|
let mockReply;
|
|
7764
7602
|
if (opts.mock) {
|
|
7765
7603
|
try {
|
|
7766
|
-
mockReply =
|
|
7604
|
+
mockReply = fs12.readFileSync(opts.mock, "utf8");
|
|
7767
7605
|
} catch {
|
|
7768
7606
|
throw new CliError(`couldn't read the --mock file: ${opts.mock}`, ExitCode.USAGE_ERROR);
|
|
7769
7607
|
}
|
|
@@ -7811,20 +7649,20 @@ function registerCode(program) {
|
|
|
7811
7649
|
process.stdout.write(JSON.stringify(line) + "\n");
|
|
7812
7650
|
};
|
|
7813
7651
|
try {
|
|
7814
|
-
const { RunOutcomeRecorder, newOneShotRunId, turnRunId } = await import('./run-outcome-
|
|
7652
|
+
const { RunOutcomeRecorder, newOneShotRunId, turnRunId } = await import('./run-outcome-4ETNDPX6.js');
|
|
7815
7653
|
const primarySlug = route.providers[0]?.model.includes("/") ? route.providers[0].model.split("/")[0] : route.providers[0]?.id;
|
|
7816
|
-
const { runCodeStreamJson, parseHostMessage } = await import('./stream-json-
|
|
7817
|
-
const { nodeCodeFs } = await import('./session-
|
|
7654
|
+
const { runCodeStreamJson, parseHostMessage } = await import('./stream-json-MD7MSSCH.js');
|
|
7655
|
+
const { nodeCodeFs } = await import('./session-22BGDYWF.js');
|
|
7818
7656
|
const readline6 = await import('readline');
|
|
7819
7657
|
const child = await import('child_process');
|
|
7820
7658
|
const { loadOrDiscoverFederation } = await import('./federation-M4ZNXOPX.js');
|
|
7821
7659
|
const { resolveExecutionEnv } = await import('./execution-env-4MS5AYAN.js');
|
|
7822
7660
|
const { resolveModelExecutionProfile, mergeModelExecutionProfile } = await import('./model-execution-profile-ELWF3Z6H.js');
|
|
7823
|
-
const { startCodeRuntimeSession } = await import('./runtime-session-
|
|
7824
|
-
const { resolveGraphBackend } = await import('./graph-backend-
|
|
7661
|
+
const { startCodeRuntimeSession } = await import('./runtime-session-RMSKXFIJ.js');
|
|
7662
|
+
const { resolveGraphBackend } = await import('./graph-backend-LK5EFQXN.js');
|
|
7825
7663
|
const { detectGitRef } = await import('./git-ref-LMT3EXYY.js');
|
|
7826
7664
|
const { repositoryIdFromRoot } = await import('./paths-RVK6FKRN.js');
|
|
7827
|
-
const { vgdRequest } = await import('./vgd-
|
|
7665
|
+
const { vgdRequest } = await import('./vgd-TW7HU2PH.js');
|
|
7828
7666
|
const federation = loadOrDiscoverFederation(root3);
|
|
7829
7667
|
const modelProfile = mergeModelExecutionProfile(
|
|
7830
7668
|
resolveModelExecutionProfile({
|
|
@@ -7882,7 +7720,7 @@ ${res.stderr}` : ""),
|
|
|
7882
7720
|
exitCode: res.status ?? 1
|
|
7883
7721
|
};
|
|
7884
7722
|
};
|
|
7885
|
-
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-
|
|
7723
|
+
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-H6I3ALUW.js');
|
|
7886
7724
|
const vgBuiltin = createVgBuiltinMcpTools({
|
|
7887
7725
|
getGraph: () => graph,
|
|
7888
7726
|
root: root3,
|
|
@@ -7903,10 +7741,10 @@ ${res.stderr}` : ""),
|
|
|
7903
7741
|
}
|
|
7904
7742
|
const externalTools = mergeExternalToolsets(vgBuiltin, projectMcp);
|
|
7905
7743
|
const { createCheckpoint } = await import('./checkpoint-UYMYMMQO.js');
|
|
7906
|
-
const
|
|
7744
|
+
const os6 = await import('os');
|
|
7907
7745
|
const pathMod = await import('path');
|
|
7908
7746
|
const checkpointIndex = pathMod.join(
|
|
7909
|
-
|
|
7747
|
+
fs12.mkdtempSync(pathMod.join(os6.tmpdir(), "vg-code-cp-")),
|
|
7910
7748
|
"index"
|
|
7911
7749
|
);
|
|
7912
7750
|
const gitRunner = (gitArgs, gitEnv) => {
|
|
@@ -7927,7 +7765,7 @@ ${res.stderr}` : ""),
|
|
|
7927
7765
|
files,
|
|
7928
7766
|
indexFile: checkpointIndex
|
|
7929
7767
|
});
|
|
7930
|
-
const { loadApprovalRules, addApprovalRule, ruleForAction, ruleLabel } = await import('./approvals-
|
|
7768
|
+
const { loadApprovalRules, addApprovalRule, ruleForAction, ruleLabel } = await import('./approvals-HRIMDIX3.js');
|
|
7931
7769
|
const { loadProjectRules, nodeRulesReader } = await import('./rules-ASYEUNB5.js');
|
|
7932
7770
|
const projectRules = loadProjectRules(nodeRulesReader(root3));
|
|
7933
7771
|
if (projectRules.sources.length && !global.quiet) {
|
|
@@ -7985,8 +7823,8 @@ ${res.stderr}` : ""),
|
|
|
7985
7823
|
};
|
|
7986
7824
|
try {
|
|
7987
7825
|
if (opts.session) {
|
|
7988
|
-
const { runCodeStreamJsonSession, STREAM_JSON_PROTOCOL_VERSION } = await import('./stream-json-
|
|
7989
|
-
const { runAgent: runAgent2 } = await import('./agent-
|
|
7826
|
+
const { runCodeStreamJsonSession, STREAM_JSON_PROTOCOL_VERSION } = await import('./stream-json-MD7MSSCH.js');
|
|
7827
|
+
const { runAgent: runAgent2 } = await import('./agent-IHNUBFBM.js');
|
|
7990
7828
|
const {
|
|
7991
7829
|
condenseSession,
|
|
7992
7830
|
loadLatestSession,
|
|
@@ -7997,7 +7835,7 @@ ${res.stderr}` : ""),
|
|
|
7997
7835
|
sessionsDir,
|
|
7998
7836
|
summarizeSession
|
|
7999
7837
|
} = await import('./session-store-AQUORKWB.js');
|
|
8000
|
-
const { VERSION: VERSION2 } = await import('./version-
|
|
7838
|
+
const { VERSION: VERSION2 } = await import('./version-FRUT6RI2.js');
|
|
8001
7839
|
const resumedRecord = typeof opts.continue === "string" ? loadSession(mainRoot, opts.continue) : opts.continue ? loadLatestSession(mainRoot) : void 0;
|
|
8002
7840
|
if (typeof opts.continue === "string" && !resumedRecord) {
|
|
8003
7841
|
emitStream({
|
|
@@ -8209,8 +8047,8 @@ ${res.stderr}` : ""),
|
|
|
8209
8047
|
if (!autonomous && !tty) {
|
|
8210
8048
|
throw usageError("the agent approves each edit/command \u2014 run in a terminal to approve interactively, or pass --auto to run autonomously (or --single for a one-shot diff).");
|
|
8211
8049
|
}
|
|
8212
|
-
const { agentTask } = await import('./interactive-
|
|
8213
|
-
const { nodeCodeFs } = await import('./session-
|
|
8050
|
+
const { agentTask } = await import('./interactive-K446F42I.js');
|
|
8051
|
+
const { nodeCodeFs } = await import('./session-22BGDYWF.js');
|
|
8214
8052
|
const { TtyPrompter } = await import('./ui-K7D3BCHD.js');
|
|
8215
8053
|
let priorSummary;
|
|
8216
8054
|
let priorInstruction;
|
|
@@ -8225,7 +8063,7 @@ ${res.stderr}` : ""),
|
|
|
8225
8063
|
}
|
|
8226
8064
|
}
|
|
8227
8065
|
const prompter = tty ? new TtyPrompter() : void 0;
|
|
8228
|
-
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-
|
|
8066
|
+
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-H6I3ALUW.js');
|
|
8229
8067
|
const vgBuiltin = createVgBuiltinMcpTools({
|
|
8230
8068
|
getGraph: () => graph,
|
|
8231
8069
|
root: root3,
|
|
@@ -8249,11 +8087,11 @@ ${res.stderr}` : ""),
|
|
|
8249
8087
|
const { loadFederation } = await import('./federation-M4ZNXOPX.js');
|
|
8250
8088
|
const { resolveExecutionEnv } = await import('./execution-env-4MS5AYAN.js');
|
|
8251
8089
|
const { resolveModelExecutionProfile, mergeModelExecutionProfile } = await import('./model-execution-profile-ELWF3Z6H.js');
|
|
8252
|
-
const { startCodeRuntimeSession } = await import('./runtime-session-
|
|
8253
|
-
const { resolveGraphBackend } = await import('./graph-backend-
|
|
8090
|
+
const { startCodeRuntimeSession } = await import('./runtime-session-RMSKXFIJ.js');
|
|
8091
|
+
const { resolveGraphBackend } = await import('./graph-backend-LK5EFQXN.js');
|
|
8254
8092
|
const { detectGitRef } = await import('./git-ref-LMT3EXYY.js');
|
|
8255
8093
|
const { repositoryIdFromRoot } = await import('./paths-RVK6FKRN.js');
|
|
8256
|
-
const { vgdRequest } = await import('./vgd-
|
|
8094
|
+
const { vgdRequest } = await import('./vgd-TW7HU2PH.js');
|
|
8257
8095
|
const federation = loadFederation(root3);
|
|
8258
8096
|
const modelProfile = mergeModelExecutionProfile(
|
|
8259
8097
|
resolveModelExecutionProfile({
|
|
@@ -8347,7 +8185,7 @@ ${res.stderr}` : ""),
|
|
|
8347
8185
|
attribution: { client: "vg-code", provider: providerSlug, model: primary?.model }
|
|
8348
8186
|
});
|
|
8349
8187
|
if (opts.out) {
|
|
8350
|
-
|
|
8188
|
+
fs12.writeFileSync(opts.out, JSON.stringify(result, null, 2) + "\n");
|
|
8351
8189
|
}
|
|
8352
8190
|
if (global.json) {
|
|
8353
8191
|
json(result);
|
|
@@ -8561,7 +8399,7 @@ async function addCmd(root3, rest, opts, asJson) {
|
|
|
8561
8399
|
}
|
|
8562
8400
|
function readPackageVersion(root3) {
|
|
8563
8401
|
try {
|
|
8564
|
-
const pkg = JSON.parse(
|
|
8402
|
+
const pkg = JSON.parse(fs12__default.readFileSync(path45__default.join(root3, "package.json"), "utf8"));
|
|
8565
8403
|
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
8566
8404
|
} catch {
|
|
8567
8405
|
return void 0;
|
|
@@ -8569,7 +8407,7 @@ function readPackageVersion(root3) {
|
|
|
8569
8407
|
}
|
|
8570
8408
|
function readOptionalFile(p) {
|
|
8571
8409
|
try {
|
|
8572
|
-
const t =
|
|
8410
|
+
const t = fs12__default.readFileSync(p, "utf8");
|
|
8573
8411
|
return t.trim() ? t : void 0;
|
|
8574
8412
|
} catch {
|
|
8575
8413
|
return void 0;
|
|
@@ -8584,8 +8422,8 @@ async function publishCmd(root3, rest, opts, global, asJson) {
|
|
|
8584
8422
|
if (!parsed) throw new CliError("publishing a private library requires a DSN \u2014 run `vibgrate login` or set VIBGRATE_DSN", ExitCode.USAGE_ERROR);
|
|
8585
8423
|
const version = (opts.version || readPackageVersion(root3) || "").trim();
|
|
8586
8424
|
if (!version) throw usageError("a --version is required (or run from a package whose package.json has a version)");
|
|
8587
|
-
const readme = readOptionalFile(opts.readme ?
|
|
8588
|
-
const dts = opts.dts ? readOptionalFile(
|
|
8425
|
+
const readme = readOptionalFile(opts.readme ? path45__default.resolve(opts.readme) : path45__default.join(root3, "README.md"));
|
|
8426
|
+
const dts = opts.dts ? readOptionalFile(path45__default.resolve(opts.dts)) : void 0;
|
|
8589
8427
|
if (!readme && !dts) throw usageError("nothing to publish \u2014 no README.md found and no --dts given");
|
|
8590
8428
|
const result = await publishPrivateLibrary(
|
|
8591
8429
|
{ name, version, readme, dts, language: opts.language },
|
|
@@ -8717,8 +8555,8 @@ function registerExport(program) {
|
|
|
8717
8555
|
out(content.trimEnd());
|
|
8718
8556
|
return;
|
|
8719
8557
|
}
|
|
8720
|
-
|
|
8721
|
-
|
|
8558
|
+
fs12.mkdirSync(path45.dirname(path45.resolve(file)), { recursive: true });
|
|
8559
|
+
fs12.writeFileSync(file, content);
|
|
8722
8560
|
info(`${c.green("\u2714")} wrote ${file} ${c.dim(`(${format})`)}`);
|
|
8723
8561
|
});
|
|
8724
8562
|
applyGlobalOptions(cmd);
|
|
@@ -8728,49 +8566,49 @@ function detectFormat(file) {
|
|
|
8728
8566
|
if (lower.endsWith(".cdx.json")) return "cyclonedx";
|
|
8729
8567
|
if (lower.endsWith(".spdx.json")) return "spdx";
|
|
8730
8568
|
if (file === "-") return "json";
|
|
8731
|
-
return formatForExt(
|
|
8569
|
+
return formatForExt(path45.extname(file));
|
|
8732
8570
|
}
|
|
8733
8571
|
function registerBundle(program) {
|
|
8734
8572
|
const cmd = program.command("bundle").description("build an air-gapped bundle (grammars + graph + library catalog)").option("--offline", "offline bundle (default; present for clarity)").option("-o, --out <dir>", "output directory", "vg-bundle").action(function(opts) {
|
|
8735
8573
|
const global = readGlobal(this);
|
|
8736
8574
|
const root3 = rootOf(global);
|
|
8737
|
-
const outDir =
|
|
8575
|
+
const outDir = path45.resolve(root3, opts.out ?? "vg-bundle");
|
|
8738
8576
|
let grammarFiles;
|
|
8739
8577
|
try {
|
|
8740
8578
|
grammarFiles = resolvedGrammarFiles();
|
|
8741
8579
|
} catch {
|
|
8742
8580
|
throw new CliError("no grammars found to bundle (run a build first)", ExitCode.ERROR);
|
|
8743
8581
|
}
|
|
8744
|
-
|
|
8582
|
+
fs12.mkdirSync(path45.join(outDir, "grammars"), { recursive: true });
|
|
8745
8583
|
let grammarCount = 0;
|
|
8746
8584
|
for (const { fileName, absPath } of grammarFiles) {
|
|
8747
|
-
|
|
8585
|
+
fs12.copyFileSync(absPath, path45.join(outDir, "grammars", fileName));
|
|
8748
8586
|
grammarCount++;
|
|
8749
8587
|
}
|
|
8750
8588
|
for (const id of Object.keys(TOOLCHAIN_GRAMMARS).sort()) {
|
|
8751
8589
|
const absPath = resolveToolchainGrammar(id);
|
|
8752
8590
|
if (!absPath) continue;
|
|
8753
|
-
|
|
8591
|
+
fs12.copyFileSync(absPath, path45.join(outDir, "grammars", path45.basename(absPath)));
|
|
8754
8592
|
grammarCount++;
|
|
8755
8593
|
}
|
|
8756
8594
|
const included = [`grammars/ (${grammarCount} .wasm)`];
|
|
8757
8595
|
const graphSrc = resolveGraphPath(root3, global.graph);
|
|
8758
|
-
if (
|
|
8759
|
-
|
|
8596
|
+
if (fs12.existsSync(graphSrc)) {
|
|
8597
|
+
fs12.copyFileSync(graphSrc, path45.join(outDir, "graph.json"));
|
|
8760
8598
|
included.push("graph.json");
|
|
8761
8599
|
} else {
|
|
8762
8600
|
const graph = loadGraphFileWithSnapshot(graphSrc);
|
|
8763
8601
|
if (graph) {
|
|
8764
|
-
|
|
8602
|
+
fs12.writeFileSync(path45.join(outDir, "graph.json"), serializeGraph(graph));
|
|
8765
8603
|
included.push("graph.json");
|
|
8766
8604
|
}
|
|
8767
8605
|
}
|
|
8768
8606
|
const cat = catalogPath(root3);
|
|
8769
|
-
if (
|
|
8770
|
-
|
|
8607
|
+
if (fs12.existsSync(cat)) {
|
|
8608
|
+
fs12.copyFileSync(cat, path45.join(outDir, "vibgrate.lib.json"));
|
|
8771
8609
|
included.push("vibgrate.lib.json");
|
|
8772
|
-
if (
|
|
8773
|
-
|
|
8610
|
+
if (fs12.existsSync(libDir(root3))) {
|
|
8611
|
+
fs12.cpSync(libDir(root3), path45.join(outDir, "lib"), { recursive: true });
|
|
8774
8612
|
included.push("lib/");
|
|
8775
8613
|
}
|
|
8776
8614
|
}
|
|
@@ -8782,15 +8620,15 @@ function registerBundle(program) {
|
|
|
8782
8620
|
included,
|
|
8783
8621
|
usage: "Run `vg build --grammars <this dir>/grammars` to build fully offline."
|
|
8784
8622
|
};
|
|
8785
|
-
|
|
8623
|
+
fs12.writeFileSync(path45.join(outDir, "MANIFEST.json"), `${stableStringify(manifest, 2)}
|
|
8786
8624
|
`);
|
|
8787
8625
|
if (global.json) {
|
|
8788
|
-
json({ out:
|
|
8626
|
+
json({ out: path45.relative(root3, outDir), ...manifest });
|
|
8789
8627
|
return;
|
|
8790
8628
|
}
|
|
8791
|
-
info(`${c.cyan("vg bundle")} \xB7 wrote ${
|
|
8629
|
+
info(`${c.cyan("vg bundle")} \xB7 wrote ${path45.relative(root3, outDir)}/`);
|
|
8792
8630
|
for (const i of included) info(` ${c.green("\u2714")} ${i}`);
|
|
8793
|
-
info(c.dim(` offline: vg build --grammars "${
|
|
8631
|
+
info(c.dim(` offline: vg build --grammars "${path45.relative(root3, outDir)}/grammars"`));
|
|
8794
8632
|
});
|
|
8795
8633
|
applyGlobalOptions(cmd);
|
|
8796
8634
|
}
|
|
@@ -8808,7 +8646,7 @@ async function runDoctor(global) {
|
|
|
8808
8646
|
const root3 = rootOf(global);
|
|
8809
8647
|
const local = global.local === true;
|
|
8810
8648
|
const graphPath = resolveGraphPath(root3, global.graph);
|
|
8811
|
-
const configFile = CONFIG_BASENAMES.find((f) =>
|
|
8649
|
+
const configFile = CONFIG_BASENAMES.find((f) => fs12.existsSync(path45.join(root3, f))) ?? null;
|
|
8812
8650
|
const graph = loadGraph(root3, graphPath);
|
|
8813
8651
|
let staleFiles = null;
|
|
8814
8652
|
if (graph) {
|
|
@@ -8834,14 +8672,14 @@ async function runDoctor(global) {
|
|
|
8834
8672
|
root: root3,
|
|
8835
8673
|
configFile,
|
|
8836
8674
|
map: {
|
|
8837
|
-
path:
|
|
8675
|
+
path: path45.relative(root3, graphPath),
|
|
8838
8676
|
built: graph !== null,
|
|
8839
8677
|
generatedAt: graph?.generatedAt ?? null,
|
|
8840
8678
|
staleFiles
|
|
8841
8679
|
},
|
|
8842
8680
|
libCatalog: {
|
|
8843
|
-
path:
|
|
8844
|
-
present:
|
|
8681
|
+
path: path45.relative(root3, catalogPath(root3)),
|
|
8682
|
+
present: fs12.existsSync(catalogPath(root3)),
|
|
8845
8683
|
libraries: libCount
|
|
8846
8684
|
},
|
|
8847
8685
|
credentials: creds,
|
|
@@ -8898,7 +8736,7 @@ async function runDoctor(global) {
|
|
|
8898
8736
|
);
|
|
8899
8737
|
info(
|
|
8900
8738
|
` host pool ${li.hostPool.size} warm session(s)` + (li.hostPool.sessions[0] ? c.dim(
|
|
8901
|
-
` \xB7 last ${
|
|
8739
|
+
` \xB7 last ${path45.basename(li.hostPool.sessions[0].modelPath)} kv=${li.hostPool.sessions[0].kvBlocks}`
|
|
8902
8740
|
) : c.dim(" \xB7 none (load via vg code / vgd host-load)"))
|
|
8903
8741
|
);
|
|
8904
8742
|
if (li.dynamicOnToken || li.dynamicCustomSampler) {
|
|
@@ -9018,7 +8856,7 @@ function registerPolicy(program) {
|
|
|
9018
8856
|
const global = readGlobal(this);
|
|
9019
8857
|
let raw;
|
|
9020
8858
|
try {
|
|
9021
|
-
raw =
|
|
8859
|
+
raw = fs12.readFileSync(file, "utf8");
|
|
9022
8860
|
} catch {
|
|
9023
8861
|
throw new CliError(`cannot read ${file}`, ExitCode.NOT_FOUND);
|
|
9024
8862
|
}
|
|
@@ -9205,9 +9043,9 @@ async function readStdin() {
|
|
|
9205
9043
|
return Buffer.concat(chunks).toString("utf-8");
|
|
9206
9044
|
}
|
|
9207
9045
|
function readFileOrThrow(file, label) {
|
|
9208
|
-
const p =
|
|
9209
|
-
if (!
|
|
9210
|
-
return
|
|
9046
|
+
const p = path45.resolve(file);
|
|
9047
|
+
if (!fs12.existsSync(p)) throw usageError(`${label} file not found: ${p}`);
|
|
9048
|
+
return fs12.readFileSync(p, "utf-8");
|
|
9211
9049
|
}
|
|
9212
9050
|
async function readInput(file, label) {
|
|
9213
9051
|
return file ? readFileOrThrow(file, label) : readStdin();
|
|
@@ -9217,10 +9055,10 @@ function writeOutput(outFile, content) {
|
|
|
9217
9055
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
9218
9056
|
return;
|
|
9219
9057
|
}
|
|
9220
|
-
const outPath =
|
|
9221
|
-
const dir =
|
|
9222
|
-
if (!
|
|
9223
|
-
|
|
9058
|
+
const outPath = path45.resolve(outFile);
|
|
9059
|
+
const dir = path45.dirname(outPath);
|
|
9060
|
+
if (!fs12.existsSync(dir)) throw usageError(`output directory does not exist: ${dir}`);
|
|
9061
|
+
fs12.writeFileSync(outPath, content.endsWith("\n") ? content : content + "\n", "utf-8");
|
|
9224
9062
|
info(c.dim(`wrote ${outPath}`));
|
|
9225
9063
|
}
|
|
9226
9064
|
function requireChoice(value, valid2, flag) {
|
|
@@ -9253,8 +9091,8 @@ function registerHcs(program) {
|
|
|
9253
9091
|
}
|
|
9254
9092
|
const statePath = opts.previous ?? opts.out;
|
|
9255
9093
|
const useIncremental = canIncremental && statePath !== void 0;
|
|
9256
|
-
const root3 =
|
|
9257
|
-
if (!
|
|
9094
|
+
const root3 = path45.resolve(dir);
|
|
9095
|
+
if (!fs12.existsSync(root3) || !fs12.statSync(root3).isDirectory()) {
|
|
9258
9096
|
throw usageError(`not a directory: ${root3}`);
|
|
9259
9097
|
}
|
|
9260
9098
|
const supported = new Set(
|
|
@@ -9272,13 +9110,13 @@ function registerHcs(program) {
|
|
|
9272
9110
|
const walk2 = (abs, rel) => {
|
|
9273
9111
|
let entries;
|
|
9274
9112
|
try {
|
|
9275
|
-
entries =
|
|
9113
|
+
entries = fs12.readdirSync(abs, { withFileTypes: true });
|
|
9276
9114
|
} catch {
|
|
9277
9115
|
return;
|
|
9278
9116
|
}
|
|
9279
9117
|
for (const entry of entries.sort((a, b) => a.name < b.name ? -1 : 1)) {
|
|
9280
9118
|
if (entry.name.startsWith(".")) continue;
|
|
9281
|
-
const absChild =
|
|
9119
|
+
const absChild = path45.join(abs, entry.name);
|
|
9282
9120
|
const relChild = rel ? `${rel}/${entry.name}` : entry.name;
|
|
9283
9121
|
if (entry.isDirectory()) {
|
|
9284
9122
|
if (!SKIP_DIRS.has(entry.name)) walk2(absChild, relChild);
|
|
@@ -9286,11 +9124,11 @@ function registerHcs(program) {
|
|
|
9286
9124
|
}
|
|
9287
9125
|
if (!entry.isFile()) continue;
|
|
9288
9126
|
if (!opts.includeTests && TEST_PATTERNS.some((p) => p.test(relChild))) continue;
|
|
9289
|
-
const lang = extToLang.get(
|
|
9127
|
+
const lang = extToLang.get(path45.extname(entry.name).toLowerCase());
|
|
9290
9128
|
if (!lang) continue;
|
|
9291
9129
|
try {
|
|
9292
|
-
if (
|
|
9293
|
-
const content =
|
|
9130
|
+
if (fs12.statSync(absChild).size > MAX_EXTRACT_FILE_BYTES) continue;
|
|
9131
|
+
const content = fs12.readFileSync(absChild, "utf-8");
|
|
9294
9132
|
let bucket = byLanguage.get(lang);
|
|
9295
9133
|
if (!bucket) byLanguage.set(lang, bucket = []);
|
|
9296
9134
|
bucket.push({ path: relChild, content });
|
|
@@ -9320,8 +9158,8 @@ function registerHcs(program) {
|
|
|
9320
9158
|
writeOutput(opts.out, parts2.join("\n"));
|
|
9321
9159
|
return;
|
|
9322
9160
|
}
|
|
9323
|
-
const previousPath =
|
|
9324
|
-
const previousNdjson = !opts.full &&
|
|
9161
|
+
const previousPath = path45.resolve(statePath);
|
|
9162
|
+
const previousNdjson = !opts.full && fs12.existsSync(previousPath) ? fs12.readFileSync(previousPath, "utf-8") : "";
|
|
9325
9163
|
if (opts.full) info(c.dim("running a full re-extraction (--full)"));
|
|
9326
9164
|
else if (!previousNdjson) info(c.dim(`previous stream not found at ${previousPath} \u2014 running a full extraction`));
|
|
9327
9165
|
const currentFilesJson = JSON.stringify(
|
|
@@ -9425,11 +9263,11 @@ function registerHcs(program) {
|
|
|
9425
9263
|
applyGlobalOptions(cmd);
|
|
9426
9264
|
}
|
|
9427
9265
|
var initCommand = new Command("init").description("Initialize vibgrate in a project").argument("[path]", "Path to initialize", ".").option("--baseline", "Create initial baseline after init").option("--yes", "Skip confirmation prompts").action(async (targetPath, opts) => {
|
|
9428
|
-
const rootDir =
|
|
9429
|
-
const vibgrateDir2 =
|
|
9266
|
+
const rootDir = path45.resolve(targetPath);
|
|
9267
|
+
const vibgrateDir2 = path45.join(rootDir, ".vibgrate");
|
|
9430
9268
|
await ensureDir(vibgrateDir2);
|
|
9431
9269
|
console.log(chalk7.green("\u2714") + ` Created ${chalk7.bold(".vibgrate/")} directory`);
|
|
9432
|
-
const configPath =
|
|
9270
|
+
const configPath = path45.join(rootDir, "vibgrate.config.ts");
|
|
9433
9271
|
if (await pathExists(configPath)) {
|
|
9434
9272
|
console.log(chalk7.dim(" vibgrate.config.ts already exists, skipping"));
|
|
9435
9273
|
} else {
|
|
@@ -9437,7 +9275,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
|
|
|
9437
9275
|
console.log(chalk7.green("\u2714") + ` Created ${chalk7.bold("vibgrate.config.ts")}`);
|
|
9438
9276
|
}
|
|
9439
9277
|
if (opts.baseline) {
|
|
9440
|
-
const { runBaseline } = await import('./baseline-
|
|
9278
|
+
const { runBaseline } = await import('./baseline-EZQ7SCRT.js');
|
|
9441
9279
|
await runBaseline(rootDir);
|
|
9442
9280
|
}
|
|
9443
9281
|
console.log("");
|
|
@@ -9540,7 +9378,7 @@ function collectPackageImports(graph, ecosystem, pkg) {
|
|
|
9540
9378
|
};
|
|
9541
9379
|
}
|
|
9542
9380
|
async function firstReferenceLine(rootDir, relFile, identifier, readFile3) {
|
|
9543
|
-
const content = await readFile3(
|
|
9381
|
+
const content = await readFile3(path45.join(rootDir, relFile));
|
|
9544
9382
|
if (!content) return null;
|
|
9545
9383
|
const escaped = identifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9546
9384
|
const re = new RegExp(`\\b${escaped}\\b`);
|
|
@@ -9578,9 +9416,9 @@ function sitesFromImportFiles(files, limit = 10) {
|
|
|
9578
9416
|
}
|
|
9579
9417
|
async function defaultReadFile(absPath) {
|
|
9580
9418
|
try {
|
|
9581
|
-
const stat2 = await
|
|
9419
|
+
const stat2 = await fs26.stat(absPath);
|
|
9582
9420
|
if (!stat2.isFile() || stat2.size > MAX_FILE_BYTES) return null;
|
|
9583
|
-
return await
|
|
9421
|
+
return await fs26.readFile(absPath, "utf8");
|
|
9584
9422
|
} catch {
|
|
9585
9423
|
return null;
|
|
9586
9424
|
}
|
|
@@ -9776,7 +9614,7 @@ var AI_ASSISTANT_DETECTORS = [
|
|
|
9776
9614
|
async function detectAiAssistant(rootDir) {
|
|
9777
9615
|
for (const detector of AI_ASSISTANT_DETECTORS) {
|
|
9778
9616
|
for (const file of detector.files) {
|
|
9779
|
-
if (await pathExists$1(
|
|
9617
|
+
if (await pathExists$1(path45.join(rootDir, file))) {
|
|
9780
9618
|
return detector.name;
|
|
9781
9619
|
}
|
|
9782
9620
|
}
|
|
@@ -9970,7 +9808,7 @@ function reportStandards(rootDir) {
|
|
|
9970
9808
|
}
|
|
9971
9809
|
async function printRuntimeSnapshot(rootDir, opts, already) {
|
|
9972
9810
|
try {
|
|
9973
|
-
const { attachVgd: attachVgd2 } = await import('./attach-
|
|
9811
|
+
const { attachVgd: attachVgd2 } = await import('./attach-L43JUJ7A.js');
|
|
9974
9812
|
const { vgdRequest } = await import('./client-P5XSRFV4.js');
|
|
9975
9813
|
const { formatSemanticProgress } = await import('./semantic-status-2JFLIQQJ.js');
|
|
9976
9814
|
let repositoryId = already?.repositoryId;
|
|
@@ -10012,7 +9850,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10012
9850
|
collectExcludes,
|
|
10013
9851
|
[]
|
|
10014
9852
|
).option("--concurrency <n>", "Max concurrent registry lookups", "8").option("--push", "Auto-push results to Vibgrate API after scan").option("--dsn <dsn>", "DSN token for push (or use VIBGRATE_DSN env)").option("--region <region>", "Override data residency region for push (us, eu)").option("--strict", "Fail on push errors").option("--ui-purpose", "Enable optional UI purpose evidence extraction (slower)").option("--no-local-artifacts", "Do not write .vibgrate JSON artifacts to disk").option("--max-privacy", "Enable strongest privacy mode (minimal scanners, no local artifacts)").option("--offline", "Run without network calls; do not upload results").option("--full", "Comprehensive scan: turns on known-vulnerability detection (= --vulns) and, when a standards policy exists, a banned-dependency report \u2014 on top of drift scoring and the code map").option("--vulns", "Also scan installed dependencies for known vulnerabilities (OSV online, or advisories from --package-manifest when offline)").option("--package-manifest <file>", "Use local package-version manifest JSON/ZIP (for offline mode)").option("--project-scan-timeout <seconds>", "Per-project scan timeout in seconds (default: 180)").option("--drift-budget <score>", "Fail if DriftScore is above budget (0-100)").option("--drift-worsening <percent>", "Fail if drift worsens by more than % since baseline").option("--repository-name <name>", "Override the repository name recorded for this scan (defaults to the directory or package.json name)").option("--force", "Always create a fresh scan ingest, even if the repository is unchanged since the last scan (skips the unchanged/reuse optimization). Used by scheduled and dashboard-triggered scans.").option("--no-graph", "Skip building the local code map (the AI/docs index) that scan produces after scoring drift").option("--no-daemon", "Never auto-start or use the local runtime (vgd) \u2014 run everything in this process").option("--quiet", "Suppress promotional output (the free-plan tracking panel and the AI Context install prompt); scan results are unaffected").action(async (targetPath, opts) => {
|
|
10015
|
-
const rootDir =
|
|
9853
|
+
const rootDir = path45.resolve(targetPath);
|
|
10016
9854
|
if (!await pathExists$1(rootDir)) {
|
|
10017
9855
|
console.error(chalk7.red(`Path does not exist: ${rootDir}`));
|
|
10018
9856
|
process.exit(1);
|
|
@@ -10020,7 +9858,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10020
9858
|
const hasDsn = !!resolveDsn(opts.dsn);
|
|
10021
9859
|
let willPush = !opts.offline && (opts.push || hasDsn);
|
|
10022
9860
|
const noLocalArtifacts = opts.localArtifacts === false;
|
|
10023
|
-
const isFirstRun = !await pathExists$1(
|
|
9861
|
+
const isFirstRun = !await pathExists$1(path45.join(rootDir, ".vibgrate", "scan_result.json"));
|
|
10024
9862
|
let pinnedRegion;
|
|
10025
9863
|
let planTier;
|
|
10026
9864
|
let upgradeUrl;
|
|
@@ -10179,7 +10017,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10179
10017
|
const advanced = await loadAdvancedScanHook();
|
|
10180
10018
|
const artifact = await runCoreScan(rootDir, scanOpts, advanced);
|
|
10181
10019
|
if (wantGraph && builtGraph) {
|
|
10182
|
-
const { attachVgd: attachVgd2 } = await import('./attach-
|
|
10020
|
+
const { attachVgd: attachVgd2 } = await import('./attach-L43JUJ7A.js');
|
|
10183
10021
|
const { ActivityLog: ActivityLog2 } = await import('./activity-MF2GNYAI.js');
|
|
10184
10022
|
const activity = new ActivityLog2();
|
|
10185
10023
|
const attached = await activity.time(
|
|
@@ -10327,7 +10165,7 @@ var SKIP_DIRS2 = /* @__PURE__ */ new Set([
|
|
|
10327
10165
|
function scanStaleness(rootDir, artifactPath) {
|
|
10328
10166
|
let ref;
|
|
10329
10167
|
try {
|
|
10330
|
-
ref =
|
|
10168
|
+
ref = fs12.statSync(artifactPath).mtimeMs;
|
|
10331
10169
|
} catch {
|
|
10332
10170
|
return { stale: false };
|
|
10333
10171
|
}
|
|
@@ -10339,7 +10177,7 @@ function scanStaleness(rootDir, artifactPath) {
|
|
|
10339
10177
|
if (depth > 8 || scanned > MAX_ENTRIES2) return;
|
|
10340
10178
|
let entries;
|
|
10341
10179
|
try {
|
|
10342
|
-
entries =
|
|
10180
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
10343
10181
|
} catch {
|
|
10344
10182
|
return;
|
|
10345
10183
|
}
|
|
@@ -10347,20 +10185,20 @@ function scanStaleness(rootDir, artifactPath) {
|
|
|
10347
10185
|
scanned++;
|
|
10348
10186
|
if (scanned > MAX_ENTRIES2) break;
|
|
10349
10187
|
if (e.isDirectory()) {
|
|
10350
|
-
if (!SKIP_DIRS2.has(e.name) && !e.name.startsWith(".")) walk2(
|
|
10188
|
+
if (!SKIP_DIRS2.has(e.name) && !e.name.startsWith(".")) walk2(path45.join(dir, e.name), depth + 1);
|
|
10351
10189
|
continue;
|
|
10352
10190
|
}
|
|
10353
10191
|
if (!WATCHED_FILES.has(e.name) && !WATCHED_EXT.test(e.name)) continue;
|
|
10354
|
-
const abs =
|
|
10192
|
+
const abs = path45.join(dir, e.name);
|
|
10355
10193
|
let mtimeMs;
|
|
10356
10194
|
try {
|
|
10357
|
-
mtimeMs =
|
|
10195
|
+
mtimeMs = fs12.statSync(abs).mtimeMs;
|
|
10358
10196
|
} catch {
|
|
10359
10197
|
continue;
|
|
10360
10198
|
}
|
|
10361
10199
|
if (mtimeMs > newest) {
|
|
10362
10200
|
newest = mtimeMs;
|
|
10363
|
-
newestChanged =
|
|
10201
|
+
newestChanged = path45.relative(rootDir, abs) || e.name;
|
|
10364
10202
|
}
|
|
10365
10203
|
}
|
|
10366
10204
|
};
|
|
@@ -10491,7 +10329,7 @@ function analyzeTree(root3, packages) {
|
|
|
10491
10329
|
if (depth > MAX_DEPTH || filesSeen >= MAX_FILES) return;
|
|
10492
10330
|
let entries;
|
|
10493
10331
|
try {
|
|
10494
|
-
entries =
|
|
10332
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
10495
10333
|
} catch {
|
|
10496
10334
|
return;
|
|
10497
10335
|
}
|
|
@@ -10500,17 +10338,17 @@ function analyzeTree(root3, packages) {
|
|
|
10500
10338
|
if (filesSeen >= MAX_FILES) return;
|
|
10501
10339
|
if (entry.isDirectory()) {
|
|
10502
10340
|
if (SKIP_DIRS3.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
10503
|
-
walk2(
|
|
10341
|
+
walk2(path45.join(dir, entry.name), depth + 1);
|
|
10504
10342
|
continue;
|
|
10505
10343
|
}
|
|
10506
|
-
const fileEco = EXT_ECOSYSTEM[
|
|
10344
|
+
const fileEco = EXT_ECOSYSTEM[path45.extname(entry.name)];
|
|
10507
10345
|
if (!fileEco || fileEco === "unknown") continue;
|
|
10508
10346
|
filesSeen++;
|
|
10509
|
-
const full =
|
|
10347
|
+
const full = path45.join(dir, entry.name);
|
|
10510
10348
|
let content;
|
|
10511
10349
|
try {
|
|
10512
|
-
if (
|
|
10513
|
-
content =
|
|
10350
|
+
if (fs12.statSync(full).size > MAX_FILE_BYTES2) continue;
|
|
10351
|
+
content = fs12.readFileSync(full, "utf8");
|
|
10514
10352
|
} catch {
|
|
10515
10353
|
continue;
|
|
10516
10354
|
}
|
|
@@ -10821,7 +10659,7 @@ function applyPlan(rootDir, upgrades, opts = {}) {
|
|
|
10821
10659
|
}
|
|
10822
10660
|
const outcomes = effective.map((t) => {
|
|
10823
10661
|
const c2 = pmCommandFor(u.ecosystem, u.package, u.to, opts.packageManager, { workspaceRoot: t.isWorkspaceRoot });
|
|
10824
|
-
return { t, res: run(c2,
|
|
10662
|
+
return { t, res: run(c2, path45.join(rootDir, t.dir)) };
|
|
10825
10663
|
});
|
|
10826
10664
|
const failures = outcomes.filter((o) => !o.res.ok);
|
|
10827
10665
|
if (failures.length === 0) {
|
|
@@ -10850,8 +10688,8 @@ function applyPlan(rootDir, upgrades, opts = {}) {
|
|
|
10850
10688
|
return results;
|
|
10851
10689
|
}
|
|
10852
10690
|
var REGISTRY_URL = "https://registry.npmjs.org/@vibgrate%2fcli/latest";
|
|
10853
|
-
var CACHE_DIR =
|
|
10854
|
-
var CACHE_FILE =
|
|
10691
|
+
var CACHE_DIR = path45.join(os.homedir(), ".vibgrate");
|
|
10692
|
+
var CACHE_FILE = path45.join(CACHE_DIR, "update-check.json");
|
|
10855
10693
|
async function fetchLatestVersion() {
|
|
10856
10694
|
try {
|
|
10857
10695
|
const controller = new AbortController();
|
|
@@ -10878,8 +10716,8 @@ async function fetchLatestVersion() {
|
|
|
10878
10716
|
}
|
|
10879
10717
|
async function writeCache(data) {
|
|
10880
10718
|
try {
|
|
10881
|
-
await
|
|
10882
|
-
await
|
|
10719
|
+
await fs26.mkdir(CACHE_DIR, { recursive: true });
|
|
10720
|
+
await fs26.writeFile(CACHE_FILE, JSON.stringify(data), "utf-8");
|
|
10883
10721
|
} catch {
|
|
10884
10722
|
}
|
|
10885
10723
|
}
|
|
@@ -10914,10 +10752,10 @@ function buildDeferredUpdateScript(opts) {
|
|
|
10914
10752
|
}
|
|
10915
10753
|
function scheduleDeferredUpdate(command, pid = process.pid, dir = os.tmpdir()) {
|
|
10916
10754
|
const stamp = `${pid}-${process.hrtime.bigint().toString(36)}`;
|
|
10917
|
-
const scriptPath =
|
|
10918
|
-
const logPath =
|
|
10755
|
+
const scriptPath = path45.join(dir, `vg-update-${stamp}.cmd`);
|
|
10756
|
+
const logPath = path45.join(dir, `vg-update-${stamp}.log`);
|
|
10919
10757
|
try {
|
|
10920
|
-
|
|
10758
|
+
fs12.writeFileSync(scriptPath, buildDeferredUpdateScript({ pid, command, logPath }), "utf8");
|
|
10921
10759
|
const child = spawn(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", scriptPath], {
|
|
10922
10760
|
detached: true,
|
|
10923
10761
|
stdio: "ignore",
|
|
@@ -10941,7 +10779,7 @@ function detectGlobalInstall(execPath = process.argv[1] || "", cwd = process.cwd
|
|
|
10941
10779
|
if (!execPath) return null;
|
|
10942
10780
|
let resolved = execPath;
|
|
10943
10781
|
try {
|
|
10944
|
-
resolved =
|
|
10782
|
+
resolved = fs12.realpathSync(execPath);
|
|
10945
10783
|
} catch {
|
|
10946
10784
|
}
|
|
10947
10785
|
const p = resolved.replace(/\\/g, "/");
|
|
@@ -10971,14 +10809,14 @@ async function findGlobalInstall(pkg = PACKAGE_NAME, run = defaultRunner) {
|
|
|
10971
10809
|
pm: "yarn",
|
|
10972
10810
|
root: () => {
|
|
10973
10811
|
const dir = tryRun("yarn global dir");
|
|
10974
|
-
return dir ?
|
|
10812
|
+
return dir ? path45.join(dir, "node_modules") : null;
|
|
10975
10813
|
}
|
|
10976
10814
|
},
|
|
10977
|
-
{ pm: "bun", root: () =>
|
|
10815
|
+
{ pm: "bun", root: () => path45.join(os.homedir(), ".bun", "install", "global", "node_modules") }
|
|
10978
10816
|
];
|
|
10979
10817
|
for (const probe of probes) {
|
|
10980
10818
|
const root3 = probe.root();
|
|
10981
|
-
if (root3 && await pathExists(
|
|
10819
|
+
if (root3 && await pathExists(path45.join(root3, pkg))) return probe.pm;
|
|
10982
10820
|
}
|
|
10983
10821
|
return null;
|
|
10984
10822
|
}
|
|
@@ -10997,15 +10835,15 @@ function getGlobalUpdateCommand(pm, pkg, version) {
|
|
|
10997
10835
|
}
|
|
10998
10836
|
}
|
|
10999
10837
|
async function detectPackageManager(cwd) {
|
|
11000
|
-
if (await pathExists(
|
|
11001
|
-
if (await pathExists(
|
|
11002
|
-
if (await pathExists(
|
|
10838
|
+
if (await pathExists(path45.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
10839
|
+
if (await pathExists(path45.join(cwd, "bun.lockb"))) return "bun";
|
|
10840
|
+
if (await pathExists(path45.join(cwd, "yarn.lock"))) return "yarn";
|
|
11003
10841
|
return "npm";
|
|
11004
10842
|
}
|
|
11005
10843
|
async function detectWorkspaceRoot(cwd) {
|
|
11006
|
-
if (await pathExists(
|
|
10844
|
+
if (await pathExists(path45.join(cwd, "pnpm-workspace.yaml"))) return true;
|
|
11007
10845
|
try {
|
|
11008
|
-
const pkgPath =
|
|
10846
|
+
const pkgPath = path45.join(cwd, "package.json");
|
|
11009
10847
|
const raw = await (await import('fs/promises')).readFile(pkgPath, "utf-8");
|
|
11010
10848
|
const pkg = JSON.parse(raw);
|
|
11011
10849
|
return pkg.workspaces != null;
|
|
@@ -11032,7 +10870,7 @@ function getInstallCommand(pm, pkg, version, isDev, opts = {}) {
|
|
|
11032
10870
|
}
|
|
11033
10871
|
async function getLocalDependencyState(cwd, pkg = PACKAGE_NAME) {
|
|
11034
10872
|
try {
|
|
11035
|
-
const pkgPath =
|
|
10873
|
+
const pkgPath = path45.join(cwd, "package.json");
|
|
11036
10874
|
const raw = await (await import('fs/promises')).readFile(pkgPath, "utf-8");
|
|
11037
10875
|
const parsed = JSON.parse(raw);
|
|
11038
10876
|
if (parsed.devDependencies?.[pkg]) return "dev";
|
|
@@ -11085,7 +10923,7 @@ ${String(err)}` }));
|
|
|
11085
10923
|
async function releaseWindowsFileLocks(cwd, keepVersion) {
|
|
11086
10924
|
reapAndReport(cwd, keepVersion);
|
|
11087
10925
|
try {
|
|
11088
|
-
const { vgdSocketPath } = await import('./vgd-
|
|
10926
|
+
const { vgdSocketPath } = await import('./vgd-TW7HU2PH.js');
|
|
11089
10927
|
const result = await stopVgd(vgdSocketPath());
|
|
11090
10928
|
if (result === "stopped") {
|
|
11091
10929
|
console.log(chalk7.dim("Stopped the vgd daemon so its files can be replaced \u2014 it restarts on the new build after the install."));
|
|
@@ -11216,7 +11054,7 @@ var updateCommand = new Command("update").description("Update vibgrate to the la
|
|
|
11216
11054
|
);
|
|
11217
11055
|
async function rewarmVgdAndReport(cwd) {
|
|
11218
11056
|
try {
|
|
11219
|
-
const { vgdIsRunning, vgdRequest } = await import('./vgd-
|
|
11057
|
+
const { vgdIsRunning, vgdRequest } = await import('./vgd-TW7HU2PH.js');
|
|
11220
11058
|
if (!await vgdIsRunning()) return;
|
|
11221
11059
|
const loaded = await vgdRequest({ op: "load-graph", root: cwd });
|
|
11222
11060
|
if (!loaded.ok || !("stored" in loaded)) return;
|
|
@@ -11327,13 +11165,13 @@ function collectCandidates(artifact) {
|
|
|
11327
11165
|
return out2;
|
|
11328
11166
|
}
|
|
11329
11167
|
var defaultFixScanner = async (rootDir) => {
|
|
11330
|
-
const scratch =
|
|
11168
|
+
const scratch = path45.join(os.tmpdir(), `vg-fix-scan-${process.pid}.json`);
|
|
11331
11169
|
const scanOpts = { vibgrateVersion: VERSION, format: "json", out: scratch, quiet: true, concurrency: 8 };
|
|
11332
11170
|
const advanced = await loadAdvancedScanHook();
|
|
11333
11171
|
return runCoreScan(rootDir, scanOpts, advanced);
|
|
11334
11172
|
};
|
|
11335
11173
|
async function loadArtifact(rootDir, inFile, scan = defaultFixScanner) {
|
|
11336
|
-
const artifactPath =
|
|
11174
|
+
const artifactPath = path45.isAbsolute(inFile) ? inFile : path45.join(rootDir, inFile);
|
|
11337
11175
|
if (await pathExists(artifactPath)) {
|
|
11338
11176
|
const staleness = scanStaleness(rootDir, artifactPath);
|
|
11339
11177
|
if (!staleness.stale) {
|
|
@@ -11360,7 +11198,7 @@ async function repositoryIdentity(rootDir, override) {
|
|
|
11360
11198
|
}
|
|
11361
11199
|
}
|
|
11362
11200
|
var fixCommand = new Command("fix").description("Get ranked, risk-tiered upgrade plans from the hosted planner and optionally apply them (prompts before changing files; --yes applies non-interactively, --dry-run previews, --no-apply only prints). Requires login/DSN.").argument("[path]", "Path to analyse", ".").option("--in <file>", "Scan artifact to read", ".vibgrate/scan_result.json").option("--format <format>", "Output format (text|json|md)", "text").option("--dsn <dsn>", 'DSN token (or use VIBGRATE_DSN env / "vg login")').option("--region <region>", "Override data residency region (us, eu)").option("--repository-name <name>", "Override the repository name recorded for this plan").option("--plan <tier>", "Apply a specific plan non-interactively (safe|balanced|aggressive)").option("--yes", "Apply the recommended plan without prompting").option("--dry-run", "Preview the recommended plan (or --plan <tier>) without applying; never prompts").option("--no-apply", "Only print the plans; never modify the project").option("--fail-on-vulns <severity>", "Exit non-zero if the recommended plan leaves an advisory at/above this severity unresolved (low|moderate|high|critical)").action(async (targetPath, opts) => {
|
|
11363
|
-
const rootDir =
|
|
11201
|
+
const rootDir = path45.resolve(targetPath);
|
|
11364
11202
|
if (!await pathExists(rootDir)) {
|
|
11365
11203
|
console.error(chalk7.red(`Path does not exist: ${rootDir}`));
|
|
11366
11204
|
process.exit(1);
|
|
@@ -11521,7 +11359,7 @@ function emit(report, format) {
|
|
|
11521
11359
|
}
|
|
11522
11360
|
}
|
|
11523
11361
|
function relProjectDir(rootDir, projectPath) {
|
|
11524
|
-
const rel =
|
|
11362
|
+
const rel = path45.isAbsolute(projectPath) ? path45.relative(rootDir, projectPath) : projectPath;
|
|
11525
11363
|
return rel === "" ? "." : rel;
|
|
11526
11364
|
}
|
|
11527
11365
|
async function buildTargetResolver(rootDir, artifact) {
|
|
@@ -12404,7 +12242,7 @@ function formatMarkdown(artifact) {
|
|
|
12404
12242
|
|
|
12405
12243
|
// src/reporting/commands/report.ts
|
|
12406
12244
|
var reportCommand = new Command("report").description("Generate a drift report from a scan artifact").option("--in <file>", "Input artifact file", ".vibgrate/scan_result.json").option("--format <format>", "Output format (md|text|json)", "text").action(async (opts) => {
|
|
12407
|
-
const artifactPath =
|
|
12245
|
+
const artifactPath = path45.resolve(opts.in);
|
|
12408
12246
|
if (!await pathExists(artifactPath)) {
|
|
12409
12247
|
console.error(chalk7.red(`Artifact not found: ${artifactPath}`));
|
|
12410
12248
|
console.error(chalk7.dim('Run "vibgrate scan" first to generate a scan artifact.'));
|
|
@@ -12453,8 +12291,8 @@ function openUrl(url) {
|
|
|
12453
12291
|
// src/reporting/commands/login.ts
|
|
12454
12292
|
var delay = (ms) => new Promise((resolve23) => setTimeout(resolve23, ms));
|
|
12455
12293
|
function isInside(dir, file) {
|
|
12456
|
-
const rel =
|
|
12457
|
-
return !!rel && !rel.startsWith("..") && !
|
|
12294
|
+
const rel = path45.relative(dir, file);
|
|
12295
|
+
return !!rel && !rel.startsWith("..") && !path45.isAbsolute(rel);
|
|
12458
12296
|
}
|
|
12459
12297
|
var loginCommand = new Command("login").description("Authenticate the CLI with your Vibgrate workspace via the browser").option("--ingest <url>", "Ingest API URL (overrides --region)").option("--region <region>", `Data residency region (${availableRegionIds().join(", ")})`, "us").option("--no-browser", "Do not attempt to open a browser automatically").option(
|
|
12460
12298
|
"--local",
|
|
@@ -12622,8 +12460,8 @@ var logoutCommand = new Command("logout").description("Clear stored Vibgrate log
|
|
|
12622
12460
|
});
|
|
12623
12461
|
|
|
12624
12462
|
// src/reporting/commands/locale/client.ts
|
|
12625
|
-
function buildUrl(scheme, host,
|
|
12626
|
-
const url = new URL(`${scheme}://${host}/v1/locale${
|
|
12463
|
+
function buildUrl(scheme, host, path47, query) {
|
|
12464
|
+
const url = new URL(`${scheme}://${host}/v1/locale${path47}`);
|
|
12627
12465
|
for (const [key2, value] of Object.entries(query ?? {})) {
|
|
12628
12466
|
if (value !== void 0 && value !== "") url.searchParams.set(key2, String(value));
|
|
12629
12467
|
}
|
|
@@ -12671,8 +12509,8 @@ function createLocaleClient(dsn) {
|
|
|
12671
12509
|
ExitCode.ERROR
|
|
12672
12510
|
);
|
|
12673
12511
|
}
|
|
12674
|
-
const request = async (method,
|
|
12675
|
-
const url = buildUrl(parsed.scheme, parsed.host,
|
|
12512
|
+
const request = async (method, path47, opts = {}) => {
|
|
12513
|
+
const url = buildUrl(parsed.scheme, parsed.host, path47, opts.query);
|
|
12676
12514
|
const body = opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
12677
12515
|
const response = await fetch(url, {
|
|
12678
12516
|
method,
|
|
@@ -12688,17 +12526,17 @@ function createLocaleClient(dsn) {
|
|
|
12688
12526
|
};
|
|
12689
12527
|
return {
|
|
12690
12528
|
workspaceId: parsed.workspaceId,
|
|
12691
|
-
get: (
|
|
12692
|
-
post: (
|
|
12693
|
-
patch: (
|
|
12694
|
-
del: (
|
|
12529
|
+
get: (path47, query) => request("GET", path47, { query }),
|
|
12530
|
+
post: (path47, body) => request("POST", path47, { body }),
|
|
12531
|
+
patch: (path47, body) => request("PATCH", path47, { body }),
|
|
12532
|
+
del: (path47, body) => request("DELETE", path47, { body })
|
|
12695
12533
|
};
|
|
12696
12534
|
}
|
|
12697
12535
|
var LOCALE_CONFIG_FILENAMES = ["vibgrate.locale.yaml", ".vibgrate/locale.yaml"];
|
|
12698
12536
|
function findLocaleConfig(cwd) {
|
|
12699
12537
|
for (const name of LOCALE_CONFIG_FILENAMES) {
|
|
12700
|
-
const candidate =
|
|
12701
|
-
if (
|
|
12538
|
+
const candidate = path45.join(cwd, name);
|
|
12539
|
+
if (fs12.existsSync(candidate)) return candidate;
|
|
12702
12540
|
}
|
|
12703
12541
|
return null;
|
|
12704
12542
|
}
|
|
@@ -12726,10 +12564,10 @@ function loadLocaleConfig(cwd) {
|
|
|
12726
12564
|
const file = findLocaleConfig(cwd);
|
|
12727
12565
|
if (!file) return { config: {}, file: null };
|
|
12728
12566
|
try {
|
|
12729
|
-
return { config: parseLocaleConfig(
|
|
12567
|
+
return { config: parseLocaleConfig(fs12.readFileSync(file, "utf8")), file };
|
|
12730
12568
|
} catch (error) {
|
|
12731
12569
|
throw new Error(
|
|
12732
|
-
`Could not parse ${
|
|
12570
|
+
`Could not parse ${path45.relative(cwd, file)}: ${error instanceof Error ? error.message : String(error)}`
|
|
12733
12571
|
);
|
|
12734
12572
|
}
|
|
12735
12573
|
}
|
|
@@ -12744,9 +12582,9 @@ function serializeLocaleConfig(config) {
|
|
|
12744
12582
|
return stringify(out2);
|
|
12745
12583
|
}
|
|
12746
12584
|
function writeLocaleConfig(cwd, config, filename) {
|
|
12747
|
-
const target = filename ??
|
|
12748
|
-
|
|
12749
|
-
|
|
12585
|
+
const target = filename ?? path45.join(cwd, LOCALE_CONFIG_FILENAMES[0]);
|
|
12586
|
+
fs12.mkdirSync(path45.dirname(target), { recursive: true });
|
|
12587
|
+
fs12.writeFileSync(target, serializeLocaleConfig(config), "utf8");
|
|
12750
12588
|
return target;
|
|
12751
12589
|
}
|
|
12752
12590
|
function resolveLocaleSettings(config, flags) {
|
|
@@ -12887,7 +12725,7 @@ function validatePathTemplate(template) {
|
|
|
12887
12725
|
if (!template.includes("{language}")) {
|
|
12888
12726
|
return 'path template must contain {language} (e.g. "src/locales/{language}/{namespace}.json").';
|
|
12889
12727
|
}
|
|
12890
|
-
if (
|
|
12728
|
+
if (path45.isAbsolute(template)) {
|
|
12891
12729
|
return "path template must be relative to the project directory.";
|
|
12892
12730
|
}
|
|
12893
12731
|
if (template.split(/[\\/]/).includes("..")) {
|
|
@@ -12903,15 +12741,15 @@ function resolveLocaleFiles(cwd, template, languages, namespaces) {
|
|
|
12903
12741
|
for (const language of languages) {
|
|
12904
12742
|
for (const namespace of namespaces) {
|
|
12905
12743
|
const relative13 = renderPath(template, language, namespace);
|
|
12906
|
-
const file =
|
|
12907
|
-
out2.push({ language, namespace, file, relative: relative13, exists:
|
|
12744
|
+
const file = path45.resolve(cwd, relative13);
|
|
12745
|
+
out2.push({ language, namespace, file, relative: relative13, exists: fs12.existsSync(file) });
|
|
12908
12746
|
}
|
|
12909
12747
|
}
|
|
12910
12748
|
return out2;
|
|
12911
12749
|
}
|
|
12912
12750
|
function readCatalog(file, format) {
|
|
12913
|
-
if (!
|
|
12914
|
-
const text =
|
|
12751
|
+
if (!fs12.existsSync(file)) return {};
|
|
12752
|
+
const text = fs12.readFileSync(file, "utf8");
|
|
12915
12753
|
try {
|
|
12916
12754
|
return codecFor(format).decode(text);
|
|
12917
12755
|
} catch (error) {
|
|
@@ -12922,11 +12760,11 @@ function readCatalog(file, format) {
|
|
|
12922
12760
|
}
|
|
12923
12761
|
function writeCatalog(file, format, catalog, opts = {}) {
|
|
12924
12762
|
const encoded = codecFor(format).encode(sortKeys(catalog));
|
|
12925
|
-
const existing =
|
|
12763
|
+
const existing = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : null;
|
|
12926
12764
|
const changed = existing !== encoded;
|
|
12927
12765
|
if (changed && !opts.dryRun) {
|
|
12928
|
-
|
|
12929
|
-
|
|
12766
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
12767
|
+
fs12.writeFileSync(file, encoded, "utf8");
|
|
12930
12768
|
}
|
|
12931
12769
|
return { file, changed, bytes: Buffer.byteLength(encoded, "utf8") };
|
|
12932
12770
|
}
|
|
@@ -12946,7 +12784,7 @@ function diffCatalogs(before, after) {
|
|
|
12946
12784
|
// src/reporting/commands/locale/index.ts
|
|
12947
12785
|
var cwdOption = ["-C, --cwd <dir>", "Run against this directory (default: current)"];
|
|
12948
12786
|
function root(opts) {
|
|
12949
|
-
return
|
|
12787
|
+
return path45.resolve(opts.cwd ?? process.cwd());
|
|
12950
12788
|
}
|
|
12951
12789
|
function withCommonOptions(cmd) {
|
|
12952
12790
|
return cmd.option(...cwdOption).option("--dsn <dsn>", 'DSN token (or use VIBGRATE_DSN, or run "vg login")').option("--project <slug>", "Locale project slug or id").option("--format <format>", `Locale file format (${SUPPORTED_FORMATS.join(", ")})`).option("--path <template>", "Path template, e.g. src/locales/{language}/{namespace}.json").option("--namespace <name>", "Restrict to one namespace").option("--language <code>", "Restrict to one BCP-47 language").option("--ver <version>", "Target version (default: latest)").option("--json", "Machine-readable output").option("-q, --quiet", "Suppress non-essential output");
|
|
@@ -13016,7 +12854,7 @@ var configCmd = withCommonOptions(
|
|
|
13016
12854
|
if (!isSupportedFormat(next2.format)) codecFor(next2.format);
|
|
13017
12855
|
const written = writeLocaleConfig(dir, next2, file ?? void 0);
|
|
13018
12856
|
emit2(opts, { file: written, config: next2 }, () => {
|
|
13019
|
-
console.log(chalk7.green(`Wrote ${
|
|
12857
|
+
console.log(chalk7.green(`Wrote ${path45.relative(dir, written) || path45.basename(written)}`));
|
|
13020
12858
|
console.log(
|
|
13021
12859
|
chalk7.dim('Credentials are not stored here \u2014 run "vg login" or set VIBGRATE_DSN.')
|
|
13022
12860
|
);
|
|
@@ -13492,7 +13330,7 @@ var vexCommand = new Command("vex").description("Generate an OpenVEX document (e
|
|
|
13492
13330
|
try {
|
|
13493
13331
|
const statements = [];
|
|
13494
13332
|
if (opts.from) {
|
|
13495
|
-
const fromPath =
|
|
13333
|
+
const fromPath = path45.resolve(opts.from);
|
|
13496
13334
|
if (!await pathExists(fromPath)) {
|
|
13497
13335
|
process.stderr.write(chalk7.red(`Statements file not found: ${fromPath}
|
|
13498
13336
|
`));
|
|
@@ -13510,9 +13348,9 @@ var vexCommand = new Command("vex").description("Generate an OpenVEX document (e
|
|
|
13510
13348
|
});
|
|
13511
13349
|
const json2 = JSON.stringify(doc, null, 2);
|
|
13512
13350
|
if (opts.out) {
|
|
13513
|
-
await writeTextFile(
|
|
13351
|
+
await writeTextFile(path45.resolve(opts.out), json2 + "\n");
|
|
13514
13352
|
process.stderr.write(
|
|
13515
|
-
chalk7.green("\u2714") + ` Wrote OpenVEX document (${doc.statements.length} statement(s)) to ${
|
|
13353
|
+
chalk7.green("\u2714") + ` Wrote OpenVEX document (${doc.statements.length} statement(s)) to ${path45.resolve(opts.out)}
|
|
13516
13354
|
`
|
|
13517
13355
|
);
|
|
13518
13356
|
} else {
|
|
@@ -13695,7 +13533,7 @@ function formatDeltaText(base, current) {
|
|
|
13695
13533
|
return lines.join("\n");
|
|
13696
13534
|
}
|
|
13697
13535
|
async function readArtifactOrExit(filePath) {
|
|
13698
|
-
const absolutePath =
|
|
13536
|
+
const absolutePath = path45.resolve(filePath);
|
|
13699
13537
|
if (!await pathExists(absolutePath)) {
|
|
13700
13538
|
console.error(chalk7.red(`Artifact not found: ${absolutePath}`));
|
|
13701
13539
|
process.exit(1);
|
|
@@ -13712,7 +13550,7 @@ var exportCommand = new Command("export").description("Export scan artifact as S
|
|
|
13712
13550
|
const sbom = format === "cyclonedx" ? toCycloneDx(artifact) : toSpdx(artifact);
|
|
13713
13551
|
const body = JSON.stringify(sbom, null, 2);
|
|
13714
13552
|
if (opts.out) {
|
|
13715
|
-
await writeTextFile(
|
|
13553
|
+
await writeTextFile(path45.resolve(opts.out), body);
|
|
13716
13554
|
console.log(chalk7.green("\u2714") + ` SBOM written to ${opts.out}`);
|
|
13717
13555
|
} else {
|
|
13718
13556
|
console.log(body);
|
|
@@ -13723,7 +13561,7 @@ var deltaCommand = new Command("delta").description("Show SBOM delta between two
|
|
|
13723
13561
|
const current = await readArtifactOrExit(opts.to);
|
|
13724
13562
|
const report = formatDeltaText(base, current);
|
|
13725
13563
|
if (opts.out) {
|
|
13726
|
-
await writeTextFile(
|
|
13564
|
+
await writeTextFile(path45.resolve(opts.out), report);
|
|
13727
13565
|
console.log(chalk7.green("\u2714") + ` SBOM delta report written to ${opts.out}`);
|
|
13728
13566
|
} else {
|
|
13729
13567
|
console.log(report);
|
|
@@ -13854,20 +13692,20 @@ function resolveRegime(id) {
|
|
|
13854
13692
|
return regime;
|
|
13855
13693
|
}
|
|
13856
13694
|
function evidenceDir(root3) {
|
|
13857
|
-
return
|
|
13695
|
+
return path45.join(root3, ".vibgrate", "evidence");
|
|
13858
13696
|
}
|
|
13859
13697
|
function orgPath(root3) {
|
|
13860
|
-
return
|
|
13698
|
+
return path45.join(evidenceDir(root3), "org.json");
|
|
13861
13699
|
}
|
|
13862
13700
|
function productsPath(root3) {
|
|
13863
|
-
return
|
|
13701
|
+
return path45.join(evidenceDir(root3), "products.json");
|
|
13864
13702
|
}
|
|
13865
13703
|
function releasesDir(root3) {
|
|
13866
|
-
return
|
|
13704
|
+
return path45.join(evidenceDir(root3), "releases");
|
|
13867
13705
|
}
|
|
13868
13706
|
function releasePath(root3, productId, version) {
|
|
13869
13707
|
const safe = `${productId}@${version}`.replace(/[^A-Za-z0-9._@-]/g, "_");
|
|
13870
|
-
return
|
|
13708
|
+
return path45.join(releasesDir(root3), `${safe}.json`);
|
|
13871
13709
|
}
|
|
13872
13710
|
var DEFAULT_ORG = {
|
|
13873
13711
|
responsiblePersons: [],
|
|
@@ -13898,7 +13736,7 @@ async function freezeRelease(root3, release) {
|
|
|
13898
13736
|
const p = releasePath(root3, release.productId, release.version);
|
|
13899
13737
|
if (await pathExists(p)) {
|
|
13900
13738
|
throw new CliError(
|
|
13901
|
-
`release ${release.productId}@${release.version} is already frozen and manifests are immutable \u2014 delete ${
|
|
13739
|
+
`release ${release.productId}@${release.version} is already frozen and manifests are immutable \u2014 delete ${path45.relative(root3, p)} only if it was frozen in error`,
|
|
13902
13740
|
ExitCode.USAGE_ERROR
|
|
13903
13741
|
);
|
|
13904
13742
|
}
|
|
@@ -13912,7 +13750,7 @@ async function loadReleases(root3, productId) {
|
|
|
13912
13750
|
const files = (await readdir(dir)).filter((f) => f.endsWith(".json")).sort();
|
|
13913
13751
|
const releases = [];
|
|
13914
13752
|
for (const f of files) {
|
|
13915
|
-
const rel = await readJsonFile(
|
|
13753
|
+
const rel = await readJsonFile(path45.join(dir, f));
|
|
13916
13754
|
if (!productId || rel.productId === productId) releases.push(rel);
|
|
13917
13755
|
}
|
|
13918
13756
|
return releases;
|
|
@@ -14607,19 +14445,19 @@ function verifyEvidenceEnvelope(env, opts = {}) {
|
|
|
14607
14445
|
var DEFAULT_KEY = "attest-key.pem";
|
|
14608
14446
|
function resolveSigningKey(root3, explicit) {
|
|
14609
14447
|
const chosen = process.env.VG_ATTEST_KEY;
|
|
14610
|
-
const keyPath = chosen ?
|
|
14448
|
+
const keyPath = chosen ? path45.resolve(chosen) : path45.join(root3, ".vibgrate", DEFAULT_KEY);
|
|
14611
14449
|
let minted = false;
|
|
14612
|
-
if (!
|
|
14450
|
+
if (!fs12.existsSync(keyPath)) {
|
|
14613
14451
|
if (chosen) throw new CliError(`signing key not found: ${chosen}`, ExitCode.USAGE_ERROR);
|
|
14614
14452
|
const kp = generateKeypair();
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14453
|
+
fs12.mkdirSync(path45.dirname(keyPath), { recursive: true });
|
|
14454
|
+
fs12.writeFileSync(keyPath, kp.privatePem, { mode: 384 });
|
|
14455
|
+
fs12.writeFileSync(`${keyPath}.pub`, kp.publicPem);
|
|
14618
14456
|
minted = true;
|
|
14619
14457
|
}
|
|
14620
14458
|
let key2;
|
|
14621
14459
|
try {
|
|
14622
|
-
key2 = crypto3.createPrivateKey(
|
|
14460
|
+
key2 = crypto3.createPrivateKey(fs12.readFileSync(keyPath, "utf8"));
|
|
14623
14461
|
} catch {
|
|
14624
14462
|
throw new CliError(`could not read an Ed25519 private key from ${keyPath}`, ExitCode.USAGE_ERROR);
|
|
14625
14463
|
}
|
|
@@ -14630,16 +14468,16 @@ function resolveSigningKey(root3, explicit) {
|
|
|
14630
14468
|
}
|
|
14631
14469
|
function writeBundle(input) {
|
|
14632
14470
|
const dir = input.outDir;
|
|
14633
|
-
|
|
14634
|
-
const write = (rel, data) =>
|
|
14471
|
+
fs12.mkdirSync(path45.join(dir, "inputs", "releases"), { recursive: true });
|
|
14472
|
+
const write = (rel, data) => fs12.writeFileSync(path45.join(dir, rel), `${JSON.stringify(data, null, 2)}
|
|
14635
14473
|
`);
|
|
14636
14474
|
write("result.json", input.result);
|
|
14637
|
-
write(
|
|
14475
|
+
write(path45.join("inputs", "advisory.json"), input.advisory);
|
|
14638
14476
|
for (const rel of input.releases) {
|
|
14639
14477
|
const safe = `${rel.productId}@${rel.version}`.replace(/[^A-Za-z0-9._@-]/g, "_");
|
|
14640
|
-
write(
|
|
14478
|
+
write(path45.join("inputs", "releases", `${safe}.json`), rel);
|
|
14641
14479
|
}
|
|
14642
|
-
write(
|
|
14480
|
+
write(path45.join("inputs", "datapack.lock"), { dataPackVersion: input.result.meta.dataPackVersion, kernelVersion: input.result.meta.kernelVersion });
|
|
14643
14481
|
write("provenance.json", {
|
|
14644
14482
|
method: "deterministic",
|
|
14645
14483
|
modelDrafted: [],
|
|
@@ -14655,13 +14493,13 @@ function writeBundle(input) {
|
|
|
14655
14493
|
disclaimer: input.regime.disclaimer
|
|
14656
14494
|
});
|
|
14657
14495
|
if (input.envelope) {
|
|
14658
|
-
|
|
14496
|
+
fs12.writeFileSync(path45.join(dir, "evidence.intoto.jsonl"), `${JSON.stringify(input.envelope)}
|
|
14659
14497
|
`);
|
|
14660
14498
|
}
|
|
14661
14499
|
if (input.timestampToken) {
|
|
14662
|
-
|
|
14500
|
+
fs12.writeFileSync(path45.join(dir, "timestamp.tsr"), input.timestampToken);
|
|
14663
14501
|
}
|
|
14664
|
-
|
|
14502
|
+
fs12.writeFileSync(path45.join(dir, "VERIFY.md"), verifyDoc(input));
|
|
14665
14503
|
return dir;
|
|
14666
14504
|
}
|
|
14667
14505
|
function verifyDoc(input) {
|
|
@@ -14722,13 +14560,13 @@ function undeterminedFields(result, regime) {
|
|
|
14722
14560
|
return gaps.filter((g) => regime.submission.requires.some((r) => g.startsWith(r)) || g.startsWith("exposure") || g.startsWith("member"));
|
|
14723
14561
|
}
|
|
14724
14562
|
async function recordDrill(root3, record) {
|
|
14725
|
-
const dir =
|
|
14726
|
-
const p =
|
|
14563
|
+
const dir = path45.join(evidenceDir(root3), "drills");
|
|
14564
|
+
const p = path45.join(dir, `${record.drillId}.json`);
|
|
14727
14565
|
await writeJsonFile(p, record);
|
|
14728
14566
|
return p;
|
|
14729
14567
|
}
|
|
14730
14568
|
async function hasRecentDrill(root3, asOf) {
|
|
14731
|
-
const dir =
|
|
14569
|
+
const dir = path45.join(evidenceDir(root3), "drills");
|
|
14732
14570
|
if (!await pathExists(dir)) return void 0;
|
|
14733
14571
|
const { readdir } = await import('fs/promises');
|
|
14734
14572
|
const { readJsonFile: readJsonFile2 } = await import('./fs-4G5A65KS.js');
|
|
@@ -14736,7 +14574,7 @@ async function hasRecentDrill(root3, asOf) {
|
|
|
14736
14574
|
if (files.length === 0) return void 0;
|
|
14737
14575
|
const cutoff = new Date(new Date(asOf).getTime() - 90 * 24 * 3600 * 1e3).toISOString();
|
|
14738
14576
|
for (const f of files) {
|
|
14739
|
-
const rec = await readJsonFile2(
|
|
14577
|
+
const rec = await readJsonFile2(path45.join(dir, f));
|
|
14740
14578
|
if (rec.ranAt >= cutoff) return true;
|
|
14741
14579
|
}
|
|
14742
14580
|
return false;
|
|
@@ -14816,7 +14654,7 @@ function formatRegimeList() {
|
|
|
14816
14654
|
|
|
14817
14655
|
// src/reporting/commands/evidence/index.ts
|
|
14818
14656
|
function root2(opts) {
|
|
14819
|
-
return
|
|
14657
|
+
return path45.resolve(opts.cwd ?? process.cwd());
|
|
14820
14658
|
}
|
|
14821
14659
|
function slug(name) {
|
|
14822
14660
|
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "product";
|
|
@@ -14904,7 +14742,7 @@ var releaseCmd = new Command("release").description("Freeze a shipped release in
|
|
|
14904
14742
|
const release = await buildRelease({
|
|
14905
14743
|
productId: product.id,
|
|
14906
14744
|
version,
|
|
14907
|
-
from:
|
|
14745
|
+
from: path45.resolve(rootDir, opts.from),
|
|
14908
14746
|
shipDate: opts.shipDate,
|
|
14909
14747
|
buildId: opts.buildId,
|
|
14910
14748
|
artefactDigest: opts.digest,
|
|
@@ -14912,7 +14750,7 @@ var releaseCmd = new Command("release").description("Freeze a shipped release in
|
|
|
14912
14750
|
frozenAt: nowIso()
|
|
14913
14751
|
});
|
|
14914
14752
|
const p = await freezeRelease(rootDir, release);
|
|
14915
|
-
console.log(chalk7.green("\u2714") + ` froze ${chalk7.bold(`${product.id}@${version}`)} \u2014 ${release.components.length} components, immutable at ${
|
|
14753
|
+
console.log(chalk7.green("\u2714") + ` froze ${chalk7.bold(`${product.id}@${version}`)} \u2014 ${release.components.length} components, immutable at ${path45.relative(rootDir, p)}`);
|
|
14916
14754
|
});
|
|
14917
14755
|
async function runExposure(rootDir, vuln, opts) {
|
|
14918
14756
|
const org = await loadOrg(rootDir);
|
|
@@ -14964,7 +14802,7 @@ var exposureCmd = new Command("exposure").description("Which shipped products co
|
|
|
14964
14802
|
console.log("\n" + buildPack(result, regime, org, stage));
|
|
14965
14803
|
}
|
|
14966
14804
|
if (opts.bundle) {
|
|
14967
|
-
const dir =
|
|
14805
|
+
const dir = path45.resolve(rootDir, opts.bundle, `evidence-${result.meta.evidenceId}`);
|
|
14968
14806
|
let envelope;
|
|
14969
14807
|
if (opts.sign !== false) {
|
|
14970
14808
|
const { key: key2, minted } = resolveSigningKey(rootDir);
|
|
@@ -14972,7 +14810,7 @@ var exposureCmd = new Command("exposure").description("Which shipped products co
|
|
|
14972
14810
|
envelope = signEvidenceStatement(buildEvidenceStatement(result, VERSION), key2);
|
|
14973
14811
|
}
|
|
14974
14812
|
writeBundle({ outDir: dir, result, advisory, releases, regime, envelope, timestampToken, cliVersion: VERSION });
|
|
14975
|
-
console.error(chalk7.green("\u2714") + ` evidence bundle written to ${
|
|
14813
|
+
console.error(chalk7.green("\u2714") + ` evidence bundle written to ${path45.relative(rootDir, dir)}${envelope ? " (signed)" : " (unsigned)"}${timestampToken ? " \xB7 RFC 3161" : ""}`);
|
|
14976
14814
|
}
|
|
14977
14815
|
process.exitCode = exposureExit(result.overallStatus);
|
|
14978
14816
|
});
|
|
@@ -15004,7 +14842,7 @@ var packCmd = new Command("pack").description("Build the submission pack a human
|
|
|
15004
14842
|
const stage = opts.stage ?? regime.clocks[0]?.stage ?? "early-warning";
|
|
15005
14843
|
const md = buildPack(result, regime, org, stage);
|
|
15006
14844
|
if (opts.out) {
|
|
15007
|
-
|
|
14845
|
+
fs12.writeFileSync(path45.resolve(rootDir, opts.out), md);
|
|
15008
14846
|
console.error(chalk7.green("\u2714") + ` pack written to ${opts.out}`);
|
|
15009
14847
|
} else {
|
|
15010
14848
|
console.log(md);
|
|
@@ -15046,20 +14884,20 @@ var drillCmd = new Command("drill").description("Timed dry-run of the determinat
|
|
|
15046
14884
|
}
|
|
15047
14885
|
});
|
|
15048
14886
|
var verifyCmd = new Command("verify").description("Verify an evidence bundle offline (no Vibgrate needed)").argument("<bundle>", "Path to an evidence bundle directory or evidence.intoto.jsonl").option("--pub <file>", "Public key PEM to pin the signer (establish trust)").action((bundlePath, opts) => {
|
|
15049
|
-
const abs =
|
|
15050
|
-
const envPath =
|
|
15051
|
-
if (!
|
|
15052
|
-
const envelope = JSON.parse(
|
|
15053
|
-
const resultPath =
|
|
15054
|
-
const result =
|
|
15055
|
-
const publicKeyPem = opts.pub ?
|
|
14887
|
+
const abs = path45.resolve(bundlePath);
|
|
14888
|
+
const envPath = fs12.statSync(abs).isDirectory() ? path45.join(abs, "evidence.intoto.jsonl") : abs;
|
|
14889
|
+
if (!fs12.existsSync(envPath)) throw new CliError(`no evidence.intoto.jsonl at ${bundlePath}`, ExitCode.NOT_FOUND);
|
|
14890
|
+
const envelope = JSON.parse(fs12.readFileSync(envPath, "utf8").trim().split("\n")[0]);
|
|
14891
|
+
const resultPath = path45.join(path45.dirname(envPath), "result.json");
|
|
14892
|
+
const result = fs12.existsSync(resultPath) ? JSON.parse(fs12.readFileSync(resultPath, "utf8")) : void 0;
|
|
14893
|
+
const publicKeyPem = opts.pub ? fs12.readFileSync(path45.resolve(opts.pub), "utf8") : void 0;
|
|
15056
14894
|
const v = verifyEvidenceEnvelope(envelope, { publicKeyPem, result });
|
|
15057
14895
|
const color = v.status === "verified" ? chalk7.green : v.status === "failed" ? chalk7.red : chalk7.yellow;
|
|
15058
14896
|
console.log(" " + color(v.status.toUpperCase()) + ` ${v.reason}`);
|
|
15059
14897
|
if (v.evidenceId) console.log(" " + chalk7.dim(`evidence ${v.evidenceId} \xB7 regime ${v.regime} \xB7 advisory ${v.advisoryId} \xB7 ${v.overallStatus}`));
|
|
15060
|
-
const tsrPath =
|
|
15061
|
-
if (
|
|
15062
|
-
const t = verifyTimestamp(
|
|
14898
|
+
const tsrPath = path45.join(path45.dirname(envPath), "timestamp.tsr");
|
|
14899
|
+
if (fs12.existsSync(tsrPath) && result) {
|
|
14900
|
+
const t = verifyTimestamp(fs12.readFileSync(tsrPath), exposureSubjectDigest(result));
|
|
15063
14901
|
const tcolor = t.imprintMatches ? chalk7.green : chalk7.red;
|
|
15064
14902
|
console.log(" " + tcolor("TIMESTAMP") + ` ${t.reason}`);
|
|
15065
14903
|
}
|
|
@@ -15126,12 +14964,12 @@ var exportCmd = new Command("export").description("Air-gap bundle of all evidenc
|
|
|
15126
14964
|
const releases = [];
|
|
15127
14965
|
for (const list of releasesByProduct.values()) releases.push(...list);
|
|
15128
14966
|
const report = computeReadiness({ regime, org, products, releasesByProduct, recentDrill: await hasRecentDrill(rootDir, today()) });
|
|
15129
|
-
const dir =
|
|
15130
|
-
await writeJsonFile(
|
|
15131
|
-
await writeJsonFile(
|
|
15132
|
-
for (const r of releases) await writeJsonFile(
|
|
15133
|
-
await writeJsonFile(
|
|
15134
|
-
console.error(chalk7.green("\u2714") + ` exported evidence state to ${
|
|
14967
|
+
const dir = path45.resolve(rootDir, opts.out);
|
|
14968
|
+
await writeJsonFile(path45.join(dir, "org.json"), org);
|
|
14969
|
+
await writeJsonFile(path45.join(dir, "products.json"), products);
|
|
14970
|
+
for (const r of releases) await writeJsonFile(path45.join(dir, "releases", `${r.productId}@${r.version}.json`.replace(/[^A-Za-z0-9._@-]/g, "_")), r);
|
|
14971
|
+
await writeJsonFile(path45.join(dir, "readiness.json"), report);
|
|
14972
|
+
console.error(chalk7.green("\u2714") + ` exported evidence state to ${path45.relative(rootDir, dir)} (${products.length} products, ${releases.length} frozen releases)`);
|
|
15135
14973
|
});
|
|
15136
14974
|
var pushCmd = new Command("push").description("Push the product registry (and an optional exposure result) to Vibgrate Cloud").option(...cwdOption2).option("--dsn <dsn>", "DSN token (or use VIBGRATE_DSN env / `vg login`)").option("--regime <id>", "Reporting regime").option("--result <file>", "An exposure result.json (or a bundle dir) to include").option("--signed", "Mark the included exposure result as signed").option("--strict", "Fail on push errors").action(async (opts) => {
|
|
15137
14975
|
const rootDir = root2(opts);
|
|
@@ -15157,10 +14995,10 @@ var pushCmd = new Command("push").description("Push the product registry (and an
|
|
|
15157
14995
|
}));
|
|
15158
14996
|
let exposure;
|
|
15159
14997
|
if (opts.result) {
|
|
15160
|
-
const raw =
|
|
15161
|
-
const resultPath =
|
|
15162
|
-
if (!
|
|
15163
|
-
exposure = JSON.parse(
|
|
14998
|
+
const raw = path45.resolve(rootDir, opts.result);
|
|
14999
|
+
const resultPath = fs12.existsSync(raw) && fs12.statSync(raw).isDirectory() ? path45.join(raw, "result.json") : raw;
|
|
15000
|
+
if (!fs12.existsSync(resultPath)) throw new CliError(`no result.json at ${opts.result}`, ExitCode.NOT_FOUND);
|
|
15001
|
+
exposure = JSON.parse(fs12.readFileSync(resultPath, "utf8"));
|
|
15164
15002
|
}
|
|
15165
15003
|
const payload = { schemaVersion: "evidence-push-1", regime: regime.id, generatedAt: nowIso(), signed: Boolean(opts.signed), products: productPayload, exposure };
|
|
15166
15004
|
const body = JSON.stringify(payload);
|
|
@@ -15359,7 +15197,7 @@ function dispatch(argv, cwd) {
|
|
|
15359
15197
|
}
|
|
15360
15198
|
const looksLikeQuestion = /\s/.test(first) || first.endsWith("?");
|
|
15361
15199
|
if (looksLikeQuestion) return ["ask", ...args];
|
|
15362
|
-
if (
|
|
15200
|
+
if (fs12.existsSync(path45.resolve(cwd, first))) {
|
|
15363
15201
|
return [hasBuildOnlyFlag(args) ? "build" : "scan", ...args];
|
|
15364
15202
|
}
|
|
15365
15203
|
const moved = MOVED_COMMANDS[first];
|
|
@@ -15386,6 +15224,7 @@ function findFirstPositional(args) {
|
|
|
15386
15224
|
async function main(argv = process.argv) {
|
|
15387
15225
|
const raw = argv.slice(2);
|
|
15388
15226
|
if (process.env.NO_COLOR || raw.includes("--no-color")) disableColor();
|
|
15227
|
+
if (!raw.includes("--local")) kickRelevanceReadiness();
|
|
15389
15228
|
const cwd = readCwd(raw);
|
|
15390
15229
|
const program = buildProgram();
|
|
15391
15230
|
program.exitOverride((err) => {
|
|
@@ -15404,9 +15243,9 @@ async function main(argv = process.argv) {
|
|
|
15404
15243
|
}
|
|
15405
15244
|
function readCwd(raw) {
|
|
15406
15245
|
const i = raw.findIndex((a) => a === "-C" || a === "--cwd");
|
|
15407
|
-
if (i >= 0 && raw[i + 1]) return
|
|
15246
|
+
if (i >= 0 && raw[i + 1]) return path45.resolve(raw[i + 1]);
|
|
15408
15247
|
const eq = raw.find((a) => a.startsWith("--cwd="));
|
|
15409
|
-
if (eq) return
|
|
15248
|
+
if (eq) return path45.resolve(eq.slice("--cwd=".length));
|
|
15410
15249
|
return process.cwd();
|
|
15411
15250
|
}
|
|
15412
15251
|
function handleError(err) {
|