@vibgrate/cli 2026.819.2 → 2026.824.3
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-ZJRWCMR6.js → agent-6SJVWFPV.js} +12 -12
- package/dist/{agent-ZJRWCMR6.js.map → agent-6SJVWFPV.js.map} +1 -1
- package/dist/{approvals-YTUXBZWQ.js → approvals-5UBLBNJF.js} +5 -5
- package/dist/{approvals-YTUXBZWQ.js.map → approvals-5UBLBNJF.js.map} +1 -1
- package/dist/{attach-WOA25VNH.js → attach-PSGCCJMA.js} +3 -3
- package/dist/{attach-WOA25VNH.js.map → attach-PSGCCJMA.js.map} +1 -1
- package/dist/baseline-HPXACNFU.js +9 -0
- package/dist/{baseline-TVRRUZGA.js.map → baseline-HPXACNFU.js.map} +1 -1
- package/dist/{chunk-24HKTTFV.js → chunk-2IY24TTR.js} +3 -3
- package/dist/{chunk-24HKTTFV.js.map → chunk-2IY24TTR.js.map} +1 -1
- package/dist/{chunk-7BSUPHX6.js → chunk-3PNAQUZM.js} +3 -3
- package/dist/{chunk-7BSUPHX6.js.map → chunk-3PNAQUZM.js.map} +1 -1
- package/dist/{chunk-W6ASIMG5.js → chunk-4PDWV4AE.js} +10 -12
- package/dist/chunk-4PDWV4AE.js.map +1 -0
- package/dist/{chunk-2ZBLZ2S3.js → chunk-5QO2GFAE.js} +27 -23
- package/dist/chunk-5QO2GFAE.js.map +1 -0
- package/dist/{chunk-GBXOAO5V.js → chunk-5UG4UHKU.js} +40 -10
- package/dist/chunk-5UG4UHKU.js.map +1 -0
- package/dist/chunk-AGOKTI77.js +6 -0
- package/dist/{chunk-ZUZHYAJK.js.map → chunk-AGOKTI77.js.map} +1 -1
- package/dist/{chunk-C2EZIAA3.js → chunk-B5GOCQFB.js} +9 -9
- package/dist/{chunk-C2EZIAA3.js.map → chunk-B5GOCQFB.js.map} +1 -1
- package/dist/{chunk-MMJFHEZ4.js → chunk-CJ2R3LVX.js} +4 -4
- package/dist/{chunk-MMJFHEZ4.js.map → chunk-CJ2R3LVX.js.map} +1 -1
- package/dist/{chunk-2C4QT5D7.js → chunk-III7S75O.js} +53 -463
- package/dist/chunk-III7S75O.js.map +1 -0
- package/dist/{chunk-IMI2VHHZ.js → chunk-IKB5U3AH.js} +3 -3
- package/dist/{chunk-IMI2VHHZ.js.map → chunk-IKB5U3AH.js.map} +1 -1
- package/dist/{chunk-AP3JN33O.js → chunk-JL66EPZ4.js} +221 -10
- package/dist/chunk-JL66EPZ4.js.map +1 -0
- package/dist/{chunk-QE6F62FR.js → chunk-KBLKNR3V.js} +3 -3
- package/dist/{chunk-QE6F62FR.js.map → chunk-KBLKNR3V.js.map} +1 -1
- package/dist/{chunk-JPOYXG7Z.js → chunk-KRE7SXSA.js} +12 -13
- package/dist/chunk-KRE7SXSA.js.map +1 -0
- package/dist/{chunk-XW2XQM3C.js → chunk-LA4CETXN.js} +3 -3
- package/dist/{chunk-XW2XQM3C.js.map → chunk-LA4CETXN.js.map} +1 -1
- package/dist/{chunk-OGFOJG4H.js → chunk-LMHKIQA5.js} +3 -3
- package/dist/{chunk-OGFOJG4H.js.map → chunk-LMHKIQA5.js.map} +1 -1
- package/dist/{chunk-FCMWHSQ6.js → chunk-M5QSBXA6.js} +17 -4
- package/dist/chunk-M5QSBXA6.js.map +1 -0
- package/dist/{chunk-R5TQBIR6.js → chunk-QLNJ3VWO.js} +3 -3
- package/dist/{chunk-R5TQBIR6.js.map → chunk-QLNJ3VWO.js.map} +1 -1
- package/dist/{chunk-XLQ4YHS3.js → chunk-QP3P4V4I.js} +10 -8
- package/dist/chunk-QP3P4V4I.js.map +1 -0
- package/dist/{chunk-BQ6NTRRK.js → chunk-RAEHWCN6.js} +6 -6
- package/dist/{chunk-BQ6NTRRK.js.map → chunk-RAEHWCN6.js.map} +1 -1
- package/dist/{chunk-USPMMVNH.js → chunk-SGIFJIII.js} +3 -3
- package/dist/{chunk-USPMMVNH.js.map → chunk-SGIFJIII.js.map} +1 -1
- package/dist/{chunk-CBL3VY7J.js → chunk-TWWVTKA7.js} +35 -14
- package/dist/chunk-TWWVTKA7.js.map +1 -0
- package/dist/chunk-USW5WHUG.js +605 -0
- package/dist/chunk-USW5WHUG.js.map +1 -0
- package/dist/{chunk-NKKOGJ63.js → chunk-UUNEUEPQ.js} +71 -9
- package/dist/chunk-UUNEUEPQ.js.map +1 -0
- package/dist/{chunk-WPLOEFZU.js → chunk-WATYIYWP.js} +3 -3
- package/dist/{chunk-WPLOEFZU.js.map → chunk-WATYIYWP.js.map} +1 -1
- package/dist/{chunk-PJRPSYFQ.js → chunk-XHIWQGRE.js} +5 -5
- package/dist/{chunk-PJRPSYFQ.js.map → chunk-XHIWQGRE.js.map} +1 -1
- package/dist/{chunk-AQZYDFEK.js → chunk-YJ23GGAJ.js} +3 -3
- package/dist/{chunk-AQZYDFEK.js.map → chunk-YJ23GGAJ.js.map} +1 -1
- package/dist/cli.js +379 -544
- package/dist/cli.js.map +1 -1
- package/dist/{daemon-YKOEP3XA.js → daemon-AEL5N4SJ.js} +9 -9
- package/dist/{daemon-YKOEP3XA.js.map → daemon-AEL5N4SJ.js.map} +1 -1
- package/dist/embed-worker-main.js +3 -3
- package/dist/{ensure-map-BLRJDO2Y.js → ensure-map-YL5NR6UH.js} +15 -15
- package/dist/{ensure-map-BLRJDO2Y.js.map → ensure-map-YL5NR6UH.js.map} +1 -1
- package/dist/{graph-backend-NTYONTWW.js → graph-backend-LEPXFPXQ.js} +7 -7
- package/dist/{graph-backend-NTYONTWW.js.map → graph-backend-LEPXFPXQ.js.map} +1 -1
- package/dist/index.d.ts +72 -130
- package/dist/index.js +15 -15
- package/dist/{interactive-B3WTC7LB.js → interactive-YJ37ZWTA.js} +27 -26
- package/dist/interactive-YJ37ZWTA.js.map +1 -0
- package/dist/load-LT6R73IZ.js +11 -0
- package/dist/{load-AJROS77R.js.map → load-LT6R73IZ.js.map} +1 -1
- package/dist/parse-worker.js +3 -2
- package/dist/parse-worker.js.map +1 -1
- package/dist/{run-outcome-SBBSTSH3.js → run-outcome-YQBPYNEY.js} +5 -5
- package/dist/{run-outcome-SBBSTSH3.js.map → run-outcome-YQBPYNEY.js.map} +1 -1
- package/dist/{runtime-session-JYYKQVDX.js → runtime-session-JSH5UL7Z.js} +9 -9
- package/dist/{runtime-session-JYYKQVDX.js.map → runtime-session-JSH5UL7Z.js.map} +1 -1
- package/dist/{session-2ZMHZ2O6.js → session-3FLVZRMM.js} +8 -8
- package/dist/{session-2ZMHZ2O6.js.map → session-3FLVZRMM.js.map} +1 -1
- package/dist/{stream-json-ZWGB4C47.js → stream-json-VJ2O52CR.js} +12 -12
- package/dist/{stream-json-ZWGB4C47.js.map → stream-json-VJ2O52CR.js.map} +1 -1
- package/dist/version-VUTM46C5.js +4 -0
- package/dist/{version-5QIEUXU6.js.map → version-VUTM46C5.js.map} +1 -1
- package/dist/{vg-mcp-bridge-4FETMJ6M.js → vg-mcp-bridge-UUMEOJSO.js} +9 -9
- package/dist/{vg-mcp-bridge-4FETMJ6M.js.map → vg-mcp-bridge-UUMEOJSO.js.map} +1 -1
- package/dist/{vgd-R524P5BJ.js → vgd-XFT574U6.js} +8 -8
- package/dist/vgd-XFT574U6.js.map +1 -0
- package/package.json +2 -1
- package/dist/baseline-TVRRUZGA.js +0 -9
- package/dist/chunk-2C4QT5D7.js.map +0 -1
- package/dist/chunk-2ZBLZ2S3.js.map +0 -1
- package/dist/chunk-AP3JN33O.js.map +0 -1
- package/dist/chunk-CA4YQBA7.js +0 -699
- package/dist/chunk-CA4YQBA7.js.map +0 -1
- package/dist/chunk-CBL3VY7J.js.map +0 -1
- package/dist/chunk-FCMWHSQ6.js.map +0 -1
- package/dist/chunk-GBXOAO5V.js.map +0 -1
- package/dist/chunk-JPOYXG7Z.js.map +0 -1
- package/dist/chunk-NKKOGJ63.js.map +0 -1
- package/dist/chunk-W6ASIMG5.js.map +0 -1
- package/dist/chunk-XLQ4YHS3.js.map +0 -1
- package/dist/chunk-ZUZHYAJK.js +0 -6
- package/dist/interactive-B3WTC7LB.js.map +0 -1
- package/dist/load-AJROS77R.js +0 -11
- package/dist/version-5QIEUXU6.js +0 -4
- package/dist/vgd-R524P5BJ.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { fetchCatalog, resolveProviders } from './chunk-
|
|
3
|
-
import { telemetryOptOut, StatsSharer, statsEndpoint, isCI } from './chunk-
|
|
4
|
-
import { loadAdvancedScanHook, baselineCommand } from './chunk-
|
|
5
|
-
import { sha256Hex, generateKeypair, dssePae, DSSE_PAYLOAD_TYPE, keyId, registerBuild, LiveStatus, ProgressBar, printLogo, runBuild } from './chunk-
|
|
6
|
-
export { runBuild } from './chunk-
|
|
2
|
+
import { fetchCatalog, resolveProviders } from './chunk-LA4CETXN.js';
|
|
3
|
+
import { telemetryOptOut, StatsSharer, statsEndpoint, isCI } from './chunk-KBLKNR3V.js';
|
|
4
|
+
import { loadAdvancedScanHook, baselineCommand } from './chunk-QLNJ3VWO.js';
|
|
5
|
+
import { sha256Hex, generateKeypair, dssePae, DSSE_PAYLOAD_TYPE, keyId, registerBuild, LiveStatus, ProgressBar, printLogo, runBuild } from './chunk-B5GOCQFB.js';
|
|
6
|
+
export { runBuild } from './chunk-B5GOCQFB.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-4PDWV4AE.js';
|
|
10
|
+
import { CONTEXT_POLICY_VERSION, computeFcsReport, renderFcsReportMarkdown, createTrajectoryCollector, runAgent } from './chunk-5QO2GFAE.js';
|
|
11
11
|
import './chunk-543E6WDJ.js';
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
12
|
+
import './chunk-IKB5U3AH.js';
|
|
13
|
+
import './chunk-YJ23GGAJ.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-UUNEUEPQ.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-RAEHWCN6.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-JL66EPZ4.js';
|
|
30
|
+
import { refreshIfStale } from './chunk-XHIWQGRE.js';
|
|
31
|
+
import { driftCount, ASSISTANTS, detectAssistants, isAssistantInstalled, detectServeLaunch, installAssistant, writeNavigationConfig, uninstallAssistant, buildGraph, writeSnapshot, probeFreshness, assistantById, SMALL_REPO_FILES } from './chunk-QP3P4V4I.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-KRE7SXSA.js';
|
|
33
33
|
import { resolveIngestHost, dashHostForIngestHost, availableRegionIds, ingestHostForRegionId } from './chunk-HTLDXEHW.js';
|
|
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-
|
|
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
35
|
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-
|
|
36
|
+
import { catalogPath, libDir, loadCatalog, driftFor, addLibrary, resolveLib, libId, resolveVersion, readDoc, localPackageDocs, localApiSurface } from './chunk-WATYIYWP.js';
|
|
37
|
+
import { recordCliCall, CLI_TOOL_ALIASES, savingsLedgerPath, clearSavings, readSavings, readUsage, readModelSavings, CAPSULE_RANKING_VERSION, SAVINGS_TOOLS, sanitizeClient } from './chunk-TWWVTKA7.js';
|
|
38
38
|
import { discoverModels } from './chunk-WNKGRXUA.js';
|
|
39
39
|
import { freeBytesOnVolume, weightStoreDir, listCachedWeights, ensureWeightCached, catalogIntegrityReport } from './chunk-57ZRSCHY.js';
|
|
40
40
|
import { CliError, ExitCode, usageError, engineUnavailable } from './chunk-MS6V5XKB.js';
|
|
41
|
-
import { attachVgd } from './chunk-
|
|
41
|
+
import { attachVgd } from './chunk-LMHKIQA5.js';
|
|
42
42
|
import { pathExists as pathExists$1, parseExcludePatterns } from './chunk-PVNALGTG.js';
|
|
43
43
|
import { ensureDir, pathExists, readJsonFile, writeTextFile, writeJsonFile } from './chunk-CRAMOEBE.js';
|
|
44
44
|
import './chunk-5IQBIXHS.js';
|
|
@@ -47,27 +47,27 @@ import { publishGraphToVgd } from './chunk-A3WWRW7U.js';
|
|
|
47
47
|
import { isRelevantChange } from './chunk-DBX3DL27.js';
|
|
48
48
|
import { inventory, enrichOnline, ECOSYSTEMS } from './chunk-6BEBJCK4.js';
|
|
49
49
|
import { resolveOne } from './chunk-J7LKEB2R.js';
|
|
50
|
-
import { queryGraphSemantic, queryGraph, indexFor, impactOf } from './chunk-
|
|
51
|
-
import { loadGraph, loadGraphPreferIndex, SCHEMA_VERSION } from './chunk-
|
|
50
|
+
import { queryGraphSemantic, queryGraph, indexFor, impactOf } from './chunk-USW5WHUG.js';
|
|
51
|
+
import { loadGraph, loadGraphPreferIndex, SCHEMA_VERSION } from './chunk-SGIFJIII.js';
|
|
52
52
|
import './chunk-VHRSG6CF.js';
|
|
53
53
|
import './chunk-6H2QV5DR.js';
|
|
54
54
|
import { discover, isSkippedDirName } from './chunk-RTURQXQL.js';
|
|
55
|
-
import { resolvedGrammarFiles, TOOLCHAIN_GRAMMARS, resolveToolchainGrammar, grammarSetVersion, fileRolesFromParseCache } from './chunk-
|
|
55
|
+
import { resolvedGrammarFiles, TOOLCHAIN_GRAMMARS, resolveToolchainGrammar, grammarSetVersion, fileRolesFromParseCache } from './chunk-M5QSBXA6.js';
|
|
56
56
|
import './chunk-T7RSQ5WD.js';
|
|
57
57
|
import './chunk-6WRG7VDO.js';
|
|
58
|
-
import { embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, unavailableMessage, countPending, modelCacheInfo, embeddingsPath, clearModelCache, withTimeout } from './chunk-
|
|
59
|
-
import { resetRelevanceProviderCache, loadRelevanceProvider,
|
|
58
|
+
import { embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, unavailableMessage, countPending, modelCacheInfo, embeddingsPath, clearModelCache, withTimeout } from './chunk-3PNAQUZM.js';
|
|
59
|
+
import { resetRelevanceProviderCache, loadRelevanceProvider, resolveGraphPath, loadTopicTags, rankQuestion, renderReport, loadGraphFileWithSnapshot, writeArtifacts, vibgrateDir, mapFileExists, ensureVibgrateGitignore } from './chunk-III7S75O.js';
|
|
60
60
|
import { cacheDir } from './chunk-MVPRPSXU.js';
|
|
61
61
|
import { serializeGraph, stableStringify, parseGraph } from './chunk-O3LABX6I.js';
|
|
62
|
-
import { VERSION } from './chunk-
|
|
62
|
+
import { VERSION } from './chunk-AGOKTI77.js';
|
|
63
63
|
import './chunk-XP6UUCZZ.js';
|
|
64
64
|
import { canonicalize, hashString } from './chunk-JFGYT6BI.js';
|
|
65
65
|
import './chunk-XQNKCA2J.js';
|
|
66
66
|
import { __toCommonJS } from './chunk-Z6ZWNWWR.js';
|
|
67
|
-
import * as
|
|
68
|
-
import
|
|
69
|
-
import * as
|
|
70
|
-
import
|
|
67
|
+
import * as fs12 from 'fs';
|
|
68
|
+
import fs12__default, { realpathSync } from 'fs';
|
|
69
|
+
import * as path45 from 'path';
|
|
70
|
+
import path45__default from 'path';
|
|
71
71
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
72
72
|
import { Command, CommanderError, Option } from 'commander';
|
|
73
73
|
import { execSync, spawn, spawnSync, execFileSync } from 'child_process';
|
|
@@ -75,11 +75,10 @@ import * as os from 'os';
|
|
|
75
75
|
import * as semver3 from 'semver';
|
|
76
76
|
import semver3__default from 'semver';
|
|
77
77
|
import * as readline from 'readline';
|
|
78
|
-
import * as zlib from 'zlib';
|
|
79
78
|
import * as crypto3 from 'crypto';
|
|
80
|
-
import { randomUUID
|
|
79
|
+
import { randomUUID } from 'crypto';
|
|
81
80
|
import chalk7 from 'chalk';
|
|
82
|
-
import * as
|
|
81
|
+
import * as fs26 from 'fs/promises';
|
|
83
82
|
import { parse, stringify } from 'yaml';
|
|
84
83
|
|
|
85
84
|
init_cli_invocation();
|
|
@@ -90,10 +89,10 @@ function registerStatus(program) {
|
|
|
90
89
|
applyGlobalOptions(cmd);
|
|
91
90
|
}
|
|
92
91
|
async function runStatus(global) {
|
|
93
|
-
const root3 =
|
|
92
|
+
const root3 = path45.resolve(global.cwd ?? ".");
|
|
94
93
|
const graphPath = resolveGraphPath(root3, global.graph);
|
|
95
94
|
const graph = loadGraph(root3, graphPath);
|
|
96
|
-
const hasCache =
|
|
95
|
+
const hasCache = fs12.existsSync(path45.join(cacheDir(root3), "parse-cache.json"));
|
|
97
96
|
let stale = null;
|
|
98
97
|
let staleExact = false;
|
|
99
98
|
if (graph) {
|
|
@@ -113,8 +112,8 @@ async function runStatus(global) {
|
|
|
113
112
|
}
|
|
114
113
|
if (global.json) {
|
|
115
114
|
json({
|
|
116
|
-
root:
|
|
117
|
-
graphPath:
|
|
115
|
+
root: path45.relative(process.cwd(), root3) || ".",
|
|
116
|
+
graphPath: path45.relative(root3, graphPath),
|
|
118
117
|
built: graph !== null,
|
|
119
118
|
generatedAt: graph?.generatedAt ?? null,
|
|
120
119
|
counts: graph?.meta.counts ?? null,
|
|
@@ -129,11 +128,11 @@ async function runStatus(global) {
|
|
|
129
128
|
return;
|
|
130
129
|
}
|
|
131
130
|
if (!graph) {
|
|
132
|
-
info(`${c.cyan("vg")} \xB7 no map yet at ${c.dim(
|
|
131
|
+
info(`${c.cyan("vg")} \xB7 no map yet at ${c.dim(path45.relative(root3, graphPath))}`);
|
|
133
132
|
info(` run ${c.bold("vg")} to build one`);
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
|
-
info(`${c.cyan("vg")} \xB7 ${
|
|
135
|
+
info(`${c.cyan("vg")} \xB7 ${path45.relative(root3, graphPath)}`);
|
|
137
136
|
info(` generated ${graph.generatedAt}`);
|
|
138
137
|
info(
|
|
139
138
|
` nodes ${c.bold(String(graph.meta.counts.nodes))} edges ${c.bold(
|
|
@@ -187,8 +186,9 @@ function registerAsk(program) {
|
|
|
187
186
|
let result;
|
|
188
187
|
let mode = "lexical";
|
|
189
188
|
let note = "";
|
|
190
|
-
|
|
191
|
-
const topicTags =
|
|
189
|
+
if (!global.local) await ensureRelevanceModule();
|
|
190
|
+
const topicTags = await loadTopicTags(graph, root3, resolveGraphPath(root3, global.graph));
|
|
191
|
+
const modRank = await rankQuestion(graph, q, { limit: 48, topicTags });
|
|
192
192
|
try {
|
|
193
193
|
if (wantSemantic) {
|
|
194
194
|
live?.set("asking the daemon\u2026");
|
|
@@ -206,8 +206,7 @@ function registerAsk(program) {
|
|
|
206
206
|
result = await queryGraphSemantic(graph, q, {
|
|
207
207
|
budget,
|
|
208
208
|
semanticRanked: ranked.ranked,
|
|
209
|
-
|
|
210
|
-
topicTags
|
|
209
|
+
ranked: modRank
|
|
211
210
|
});
|
|
212
211
|
mode = `semantic (vgd${ranked.model ? `, ${ranked.model}` : ""})`;
|
|
213
212
|
activity.add("answer", "ok", "answered from the daemon index \u2014 no local model load");
|
|
@@ -230,18 +229,18 @@ function registerAsk(program) {
|
|
|
230
229
|
const bar = !global.json ? new ProgressBar(c.dim("embedding")) : void 0;
|
|
231
230
|
const vectors = await getNodeEmbeddings(graph, embedder, root3, bar ? (d, t) => bar.update(d, t) : void 0);
|
|
232
231
|
bar?.done();
|
|
233
|
-
result = await queryGraphSemantic(graph, q, { budget, embedder, nodeVectors: vectors,
|
|
232
|
+
result = await queryGraphSemantic(graph, q, { budget, embedder, nodeVectors: vectors, ranked: modRank });
|
|
234
233
|
mode = `semantic (${embedder.id})`;
|
|
235
234
|
activity.add("answer", "ok", `answered in this process \xB7 ${embedder.id} \xB7 ${vectors.size} vector(s)`);
|
|
236
235
|
} else {
|
|
237
|
-
result = queryGraph(graph, q, { budget,
|
|
236
|
+
result = queryGraph(graph, q, { budget, ranked: modRank });
|
|
238
237
|
note = reason ? unavailableMessage(reason) : "semantic unavailable; used lexical";
|
|
239
238
|
if (detail) note += ` (${detail})`;
|
|
240
239
|
activity.add("answer", "warn", `lexical only \u2014 ${note}`);
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
} else {
|
|
244
|
-
result = queryGraph(graph, q, { budget,
|
|
243
|
+
result = queryGraph(graph, q, { budget, ranked: modRank });
|
|
245
244
|
if (global.local) note = "semantic skipped under --local; used lexical";
|
|
246
245
|
activity.add("answer", "skip", global.local ? "lexical only (--local)" : "lexical only (--no-semantic)");
|
|
247
246
|
}
|
|
@@ -309,15 +308,15 @@ function crashedMessage(signal) {
|
|
|
309
308
|
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
309
|
}
|
|
311
310
|
function defaultCacheDir() {
|
|
312
|
-
const base = process.env.XDG_CACHE_HOME ||
|
|
313
|
-
return
|
|
311
|
+
const base = process.env.XDG_CACHE_HOME || path45.join(os.homedir(), ".cache");
|
|
312
|
+
return path45.join(base, "vibgrate", "models");
|
|
314
313
|
}
|
|
315
314
|
function verdictPath(dir) {
|
|
316
|
-
return
|
|
315
|
+
return path45.join(dir, `embed-health-${process.platform}-${process.arch}.json`);
|
|
317
316
|
}
|
|
318
317
|
function readVerdict(dir) {
|
|
319
318
|
try {
|
|
320
|
-
const raw = JSON.parse(
|
|
319
|
+
const raw = JSON.parse(fs12.readFileSync(verdictPath(dir), "utf8"));
|
|
321
320
|
if (raw?.status !== "ok" && raw?.status !== "crashed") return null;
|
|
322
321
|
if (raw.version !== VERSION) return null;
|
|
323
322
|
return raw;
|
|
@@ -327,18 +326,18 @@ function readVerdict(dir) {
|
|
|
327
326
|
}
|
|
328
327
|
function writeVerdict(dir, verdict) {
|
|
329
328
|
try {
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
330
|
+
fs12.writeFileSync(verdictPath(dir), JSON.stringify(verdict, null, 2) + "\n", "utf8");
|
|
332
331
|
} catch {
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
334
|
function probeModuleUrl(from = import.meta.url) {
|
|
336
|
-
const dir =
|
|
335
|
+
const dir = path45.dirname(fileURLToPath(from));
|
|
337
336
|
for (const name of ["embeddings.js", "index.js"]) {
|
|
338
|
-
const candidate =
|
|
339
|
-
if (
|
|
337
|
+
const candidate = path45.join(dir, name);
|
|
338
|
+
if (fs12.existsSync(candidate)) return pathToFileURL(candidate).href;
|
|
340
339
|
}
|
|
341
|
-
return pathToFileURL(
|
|
340
|
+
return pathToFileURL(path45.join(dir, "index.js")).href;
|
|
342
341
|
}
|
|
343
342
|
function defaultRunProbe(timeoutMs) {
|
|
344
343
|
const moduleUrl = probeModuleUrl();
|
|
@@ -416,7 +415,7 @@ async function embedderHealth(options = {}) {
|
|
|
416
415
|
}
|
|
417
416
|
function clearEmbedderHealth(cacheDir2) {
|
|
418
417
|
try {
|
|
419
|
-
|
|
418
|
+
fs12.unlinkSync(verdictPath(cacheDir2 ?? defaultCacheDir()));
|
|
420
419
|
} catch {
|
|
421
420
|
}
|
|
422
421
|
}
|
|
@@ -1091,12 +1090,12 @@ var PUBLISH_INTERVAL_MS = 2e3;
|
|
|
1091
1090
|
var KEEPALIVE_MS = 1e4;
|
|
1092
1091
|
var STALE_MS = 6e4;
|
|
1093
1092
|
function liveStatsDir(root3) {
|
|
1094
|
-
return
|
|
1093
|
+
return path45.join(cacheDir(root3), "serve-live");
|
|
1095
1094
|
}
|
|
1096
1095
|
function reapOtherVersionServers(dir, keepVersion, now = Date.now(), kill = (pid, signal) => process.kill(pid, signal), selfPid = process.pid) {
|
|
1097
1096
|
let entries;
|
|
1098
1097
|
try {
|
|
1099
|
-
entries =
|
|
1098
|
+
entries = fs12.readdirSync(dir);
|
|
1100
1099
|
} catch {
|
|
1101
1100
|
return [];
|
|
1102
1101
|
}
|
|
@@ -1105,7 +1104,7 @@ function reapOtherVersionServers(dir, keepVersion, now = Date.now(), kill = (pid
|
|
|
1105
1104
|
if (!/^serve-\d+\.json$/.test(name)) continue;
|
|
1106
1105
|
let parsed;
|
|
1107
1106
|
try {
|
|
1108
|
-
parsed = JSON.parse(
|
|
1107
|
+
parsed = JSON.parse(fs12.readFileSync(path45.join(dir, name), "utf8"));
|
|
1109
1108
|
} catch {
|
|
1110
1109
|
continue;
|
|
1111
1110
|
}
|
|
@@ -1127,7 +1126,7 @@ var LiveStatsBus = class {
|
|
|
1127
1126
|
this.dir = dir;
|
|
1128
1127
|
this.stats = stats;
|
|
1129
1128
|
this.pid = pid;
|
|
1130
|
-
this.file =
|
|
1129
|
+
this.file = path45.join(dir, `serve-${this.pid}.json`);
|
|
1131
1130
|
}
|
|
1132
1131
|
dir;
|
|
1133
1132
|
stats;
|
|
@@ -1159,10 +1158,10 @@ var LiveStatsBus = class {
|
|
|
1159
1158
|
this.lastWriteAt = now;
|
|
1160
1159
|
const body = { pid: this.pid, updatedAt: now, version: VERSION, snapshot: snap };
|
|
1161
1160
|
try {
|
|
1162
|
-
|
|
1161
|
+
fs12.mkdirSync(this.dir, { recursive: true });
|
|
1163
1162
|
const tmp = `${this.file}.tmp`;
|
|
1164
|
-
|
|
1165
|
-
|
|
1163
|
+
fs12.writeFileSync(tmp, JSON.stringify(body));
|
|
1164
|
+
fs12.renameSync(tmp, this.file);
|
|
1166
1165
|
} catch {
|
|
1167
1166
|
}
|
|
1168
1167
|
}
|
|
@@ -1173,24 +1172,24 @@ var LiveStatsBus = class {
|
|
|
1173
1172
|
siblings(now = Date.now()) {
|
|
1174
1173
|
let entries;
|
|
1175
1174
|
try {
|
|
1176
|
-
entries =
|
|
1175
|
+
entries = fs12.readdirSync(this.dir);
|
|
1177
1176
|
} catch {
|
|
1178
1177
|
return [];
|
|
1179
1178
|
}
|
|
1180
1179
|
const out2 = [];
|
|
1181
1180
|
for (const name of entries.sort()) {
|
|
1182
1181
|
if (!/^serve-\d+\.json$/.test(name)) continue;
|
|
1183
|
-
const file =
|
|
1182
|
+
const file = path45.join(this.dir, name);
|
|
1184
1183
|
let parsed;
|
|
1185
1184
|
try {
|
|
1186
|
-
parsed = JSON.parse(
|
|
1185
|
+
parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
1187
1186
|
} catch {
|
|
1188
1187
|
continue;
|
|
1189
1188
|
}
|
|
1190
1189
|
if (typeof parsed?.pid !== "number" || typeof parsed.updatedAt !== "number" || !parsed.snapshot?.totals) continue;
|
|
1191
1190
|
if (now - parsed.updatedAt > STALE_MS) {
|
|
1192
1191
|
try {
|
|
1193
|
-
|
|
1192
|
+
fs12.unlinkSync(file);
|
|
1194
1193
|
} catch {
|
|
1195
1194
|
}
|
|
1196
1195
|
continue;
|
|
@@ -1202,7 +1201,7 @@ var LiveStatsBus = class {
|
|
|
1202
1201
|
}
|
|
1203
1202
|
unlinkOwn = () => {
|
|
1204
1203
|
try {
|
|
1205
|
-
|
|
1204
|
+
fs12.unlinkSync(this.file);
|
|
1206
1205
|
} catch {
|
|
1207
1206
|
}
|
|
1208
1207
|
};
|
|
@@ -1515,12 +1514,12 @@ var LedgerTail = class {
|
|
|
1515
1514
|
if (size === this.offset) return;
|
|
1516
1515
|
let chunk;
|
|
1517
1516
|
try {
|
|
1518
|
-
const fd =
|
|
1517
|
+
const fd = fs12.openSync(this.file, "r");
|
|
1519
1518
|
try {
|
|
1520
1519
|
chunk = Buffer.alloc(size - this.offset);
|
|
1521
|
-
|
|
1520
|
+
fs12.readSync(fd, chunk, 0, chunk.length, this.offset);
|
|
1522
1521
|
} finally {
|
|
1523
|
-
|
|
1522
|
+
fs12.closeSync(fd);
|
|
1524
1523
|
}
|
|
1525
1524
|
} catch {
|
|
1526
1525
|
return;
|
|
@@ -1533,7 +1532,7 @@ var LedgerTail = class {
|
|
|
1533
1532
|
}
|
|
1534
1533
|
sizeOf() {
|
|
1535
1534
|
try {
|
|
1536
|
-
return
|
|
1535
|
+
return fs12.statSync(this.file).size;
|
|
1537
1536
|
} catch {
|
|
1538
1537
|
return 0;
|
|
1539
1538
|
}
|
|
@@ -1826,10 +1825,10 @@ var Connection = class {
|
|
|
1826
1825
|
};
|
|
1827
1826
|
function projectDir(root3, projectPath) {
|
|
1828
1827
|
const rel = projectPath === "" || projectPath === "." ? "" : projectPath;
|
|
1829
|
-
return rel ?
|
|
1828
|
+
return rel ? path45.resolve(root3, rel) : path45.resolve(root3);
|
|
1830
1829
|
}
|
|
1831
1830
|
function projectForFile(root3, projects, filePath) {
|
|
1832
|
-
const dir =
|
|
1831
|
+
const dir = path45.dirname(path45.resolve(filePath));
|
|
1833
1832
|
for (const proj of projects) {
|
|
1834
1833
|
if (projectDir(root3, proj.path) === dir) return proj;
|
|
1835
1834
|
}
|
|
@@ -1838,7 +1837,7 @@ function projectForFile(root3, projects, filePath) {
|
|
|
1838
1837
|
let bestLen = -1;
|
|
1839
1838
|
for (const proj of projects) {
|
|
1840
1839
|
const projDir = projectDir(root3, proj.path);
|
|
1841
|
-
if ((dir === projDir || dir.startsWith(projDir +
|
|
1840
|
+
if ((dir === projDir || dir.startsWith(projDir + path45.sep)) && projDir.length > bestLen) {
|
|
1842
1841
|
best = proj;
|
|
1843
1842
|
bestLen = projDir.length;
|
|
1844
1843
|
}
|
|
@@ -1848,7 +1847,7 @@ function projectForFile(root3, projects, filePath) {
|
|
|
1848
1847
|
var MAX_ENTRIES = 1e3;
|
|
1849
1848
|
var KEEP_ENTRIES = 500;
|
|
1850
1849
|
function historyPath(root3) {
|
|
1851
|
-
return
|
|
1850
|
+
return path45.join(root3, ".vibgrate", "score-history.jsonl");
|
|
1852
1851
|
}
|
|
1853
1852
|
function parseLine(line) {
|
|
1854
1853
|
try {
|
|
@@ -1862,7 +1861,7 @@ function parseLine(line) {
|
|
|
1862
1861
|
}
|
|
1863
1862
|
function readHistory(root3) {
|
|
1864
1863
|
try {
|
|
1865
|
-
return
|
|
1864
|
+
return fs12.readFileSync(historyPath(root3), "utf8").split("\n").filter((l) => l.trim()).map(parseLine).filter((e) => e !== null);
|
|
1866
1865
|
} catch {
|
|
1867
1866
|
return [];
|
|
1868
1867
|
}
|
|
@@ -1889,14 +1888,14 @@ function recordScore(root3, entry) {
|
|
|
1889
1888
|
}
|
|
1890
1889
|
}
|
|
1891
1890
|
const file = historyPath(root3);
|
|
1892
|
-
|
|
1891
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
1893
1892
|
ensureVibgrateGitignore(root3);
|
|
1894
|
-
|
|
1893
|
+
fs12.appendFileSync(file, `${JSON.stringify(entry)}
|
|
1895
1894
|
`);
|
|
1896
1895
|
const all = readHistory(root3);
|
|
1897
1896
|
if (all.length > MAX_ENTRIES) {
|
|
1898
1897
|
const kept = all.slice(-KEEP_ENTRIES);
|
|
1899
|
-
|
|
1898
|
+
fs12.writeFileSync(file, kept.map((e) => JSON.stringify(e)).join("\n") + "\n");
|
|
1900
1899
|
}
|
|
1901
1900
|
} catch {
|
|
1902
1901
|
}
|
|
@@ -1907,7 +1906,7 @@ function deltaFrom(prev, current) {
|
|
|
1907
1906
|
return current.score - prev.score;
|
|
1908
1907
|
}
|
|
1909
1908
|
function ignoreFilePath(root3) {
|
|
1910
|
-
return
|
|
1909
|
+
return path45.join(root3, ".vibgrate", "ignore.json");
|
|
1911
1910
|
}
|
|
1912
1911
|
function isActive(entry, now = Date.now()) {
|
|
1913
1912
|
if (!entry.until) return true;
|
|
@@ -1919,7 +1918,7 @@ function readIgnores(root3, now = Date.now()) {
|
|
|
1919
1918
|
const out2 = /* @__PURE__ */ new Map();
|
|
1920
1919
|
let raw;
|
|
1921
1920
|
try {
|
|
1922
|
-
raw =
|
|
1921
|
+
raw = fs12.readFileSync(ignoreFilePath(root3), "utf8");
|
|
1923
1922
|
} catch {
|
|
1924
1923
|
return out2;
|
|
1925
1924
|
}
|
|
@@ -1939,14 +1938,14 @@ function readIgnores(root3, now = Date.now()) {
|
|
|
1939
1938
|
return out2;
|
|
1940
1939
|
}
|
|
1941
1940
|
function inventoryPath(root3) {
|
|
1942
|
-
return
|
|
1941
|
+
return path45.join(root3, ".vibgrate", "inline-inventory.json");
|
|
1943
1942
|
}
|
|
1944
1943
|
function inventoryKey(projectPath, pkg) {
|
|
1945
1944
|
return `${projectPath}::${pkg}`;
|
|
1946
1945
|
}
|
|
1947
1946
|
function readInventory(root3) {
|
|
1948
1947
|
try {
|
|
1949
|
-
const parsed = JSON.parse(
|
|
1948
|
+
const parsed = JSON.parse(fs12.readFileSync(inventoryPath(root3), "utf8"));
|
|
1950
1949
|
if (typeof parsed.ts === "string" && typeof parsed.methodology === "string" && Array.isArray(parsed.drifted) && parsed.drifted.every((d) => typeof d === "string")) {
|
|
1951
1950
|
return parsed;
|
|
1952
1951
|
}
|
|
@@ -1957,7 +1956,7 @@ function readInventory(root3) {
|
|
|
1957
1956
|
function recordInventory(root3, snap) {
|
|
1958
1957
|
try {
|
|
1959
1958
|
ensureVibgrateGitignore(root3);
|
|
1960
|
-
|
|
1959
|
+
fs12.writeFileSync(inventoryPath(root3), `${JSON.stringify(snap)}
|
|
1961
1960
|
`);
|
|
1962
1961
|
} catch {
|
|
1963
1962
|
}
|
|
@@ -2889,7 +2888,7 @@ var VibgrateLanguageServer = class {
|
|
|
2889
2888
|
* the workspace scan cache (billing / repo score stay on the official scan).
|
|
2890
2889
|
*/
|
|
2891
2890
|
async scanOpenManifest(uri, filePath) {
|
|
2892
|
-
const relDir =
|
|
2891
|
+
const relDir = path45.relative(this.opts.root, path45.dirname(path45.resolve(filePath)));
|
|
2893
2892
|
const key2 = relDir === "" ? "." : relDir;
|
|
2894
2893
|
if (this.openManifestScans.has(key2) || this.openManifestFailed.has(key2)) return;
|
|
2895
2894
|
if (key2 === "." || key2.startsWith("..")) return;
|
|
@@ -2909,7 +2908,7 @@ var VibgrateLanguageServer = class {
|
|
|
2909
2908
|
quiet: true,
|
|
2910
2909
|
vibgrateVersion: VERSION
|
|
2911
2910
|
};
|
|
2912
|
-
const sub = await runCoreScanSilently(
|
|
2911
|
+
const sub = await runCoreScanSilently(path45.dirname(filePath), scanOpts, advanced);
|
|
2913
2912
|
const proj = (sub.projects ?? []).find((p) => p.path === "." || p.path === "") ?? sub.projects?.[0];
|
|
2914
2913
|
if (!proj || !this.artifact) {
|
|
2915
2914
|
this.openManifestFailed.add(key2);
|
|
@@ -3217,10 +3216,10 @@ var VibgrateLanguageServer = class {
|
|
|
3217
3216
|
const ecosystem = osvEcosystem(proj.type);
|
|
3218
3217
|
if (!ecosystem) continue;
|
|
3219
3218
|
const relManifest = manifestRelativePath(proj);
|
|
3220
|
-
const absManifest =
|
|
3219
|
+
const absManifest = path45.resolve(this.opts.root, relManifest);
|
|
3221
3220
|
let text = null;
|
|
3222
3221
|
try {
|
|
3223
|
-
if (
|
|
3222
|
+
if (fs12.existsSync(absManifest)) text = fs12.readFileSync(absManifest, "utf8");
|
|
3224
3223
|
} catch {
|
|
3225
3224
|
text = null;
|
|
3226
3225
|
}
|
|
@@ -3410,7 +3409,7 @@ function pruneArtifactProjects(a) {
|
|
|
3410
3409
|
return { ...a, projects, findings };
|
|
3411
3410
|
}
|
|
3412
3411
|
function projectByPath(a, projectPath) {
|
|
3413
|
-
const norm = (p) =>
|
|
3412
|
+
const norm = (p) => path45.normalize((p === "" ? "." : p).replace(/\\/g, "/"));
|
|
3414
3413
|
const want = norm(projectPath);
|
|
3415
3414
|
for (const proj of a.projects ?? []) {
|
|
3416
3415
|
if (norm(proj.path) === want) return proj;
|
|
@@ -3452,7 +3451,7 @@ function projectForFile2(root3, a, filePath) {
|
|
|
3452
3451
|
return projectForFile(root3, a.projects ?? [], filePath);
|
|
3453
3452
|
}
|
|
3454
3453
|
function sameProject(location, projectPath) {
|
|
3455
|
-
return
|
|
3454
|
+
return path45.normalize(location) === path45.normalize(projectPath);
|
|
3456
3455
|
}
|
|
3457
3456
|
function hasReleaseDates(a) {
|
|
3458
3457
|
for (const proj of a.projects ?? []) {
|
|
@@ -3522,10 +3521,10 @@ function buildBreakdown(rootDir, projects) {
|
|
|
3522
3521
|
const relManifest = manifestRelativePath(p);
|
|
3523
3522
|
if (isPrunedWorkspacePath(p.path) || isPrunedWorkspacePath(relManifest)) continue;
|
|
3524
3523
|
const ecosystem = osvEcosystem(p.type);
|
|
3525
|
-
const absManifest =
|
|
3524
|
+
const absManifest = path45.resolve(rootDir, relManifest);
|
|
3526
3525
|
let text = null;
|
|
3527
3526
|
try {
|
|
3528
|
-
if (
|
|
3527
|
+
if (fs12.existsSync(absManifest)) text = fs12.readFileSync(absManifest, "utf8");
|
|
3529
3528
|
} catch {
|
|
3530
3529
|
text = null;
|
|
3531
3530
|
}
|
|
@@ -3590,34 +3589,34 @@ function buildBreakdown(rootDir, projects) {
|
|
|
3590
3589
|
}
|
|
3591
3590
|
function manifestRelativePath(proj) {
|
|
3592
3591
|
const base = proj.path === "." || proj.path === "" ? "" : proj.path;
|
|
3593
|
-
const
|
|
3592
|
+
const join34 = (name) => base ? path45.join(base, name) : name;
|
|
3594
3593
|
switch (proj.type) {
|
|
3595
3594
|
case "node":
|
|
3596
3595
|
case "typescript":
|
|
3597
|
-
return
|
|
3596
|
+
return join34("package.json");
|
|
3598
3597
|
case "python":
|
|
3599
|
-
return
|
|
3598
|
+
return join34("pyproject.toml");
|
|
3600
3599
|
case "go":
|
|
3601
|
-
return
|
|
3600
|
+
return join34("go.mod");
|
|
3602
3601
|
case "rust":
|
|
3603
|
-
return
|
|
3602
|
+
return join34("Cargo.toml");
|
|
3604
3603
|
case "ruby":
|
|
3605
|
-
return
|
|
3604
|
+
return join34("Gemfile");
|
|
3606
3605
|
case "php":
|
|
3607
|
-
return
|
|
3606
|
+
return join34("composer.json");
|
|
3608
3607
|
case "java":
|
|
3609
3608
|
case "kotlin":
|
|
3610
3609
|
case "scala":
|
|
3611
3610
|
case "groovy":
|
|
3612
|
-
return
|
|
3611
|
+
return join34("pom.xml");
|
|
3613
3612
|
case "dotnet":
|
|
3614
|
-
return
|
|
3613
|
+
return join34(proj.name ? `${proj.name}.csproj` : "Directory.Build.props");
|
|
3615
3614
|
case "dart":
|
|
3616
|
-
return
|
|
3615
|
+
return join34("pubspec.yaml");
|
|
3617
3616
|
case "elixir":
|
|
3618
|
-
return
|
|
3617
|
+
return join34("mix.exs");
|
|
3619
3618
|
default:
|
|
3620
|
-
return
|
|
3619
|
+
return join34("package.json");
|
|
3621
3620
|
}
|
|
3622
3621
|
}
|
|
3623
3622
|
function lockfileRelativePath(rootDir, proj) {
|
|
@@ -3648,9 +3647,9 @@ function lockfileRelativePath(rootDir, proj) {
|
|
|
3648
3647
|
const dirsToTry = base ? [base, ""] : [""];
|
|
3649
3648
|
for (const dir of dirsToTry) {
|
|
3650
3649
|
for (const name of candidateNames) {
|
|
3651
|
-
const rel = dir ?
|
|
3650
|
+
const rel = dir ? path45.join(dir, name) : name;
|
|
3652
3651
|
try {
|
|
3653
|
-
if (
|
|
3652
|
+
if (fs12.existsSync(path45.join(rootDir, rel))) return rel;
|
|
3654
3653
|
} catch {
|
|
3655
3654
|
}
|
|
3656
3655
|
}
|
|
@@ -3721,10 +3720,10 @@ function lookupImportFiles(map, pkg) {
|
|
|
3721
3720
|
}
|
|
3722
3721
|
function firstPackageMentionLine(root3, relFile, pkg) {
|
|
3723
3722
|
try {
|
|
3724
|
-
const abs =
|
|
3725
|
-
const stat2 =
|
|
3723
|
+
const abs = path45.resolve(root3, relFile);
|
|
3724
|
+
const stat2 = fs12.statSync(abs);
|
|
3726
3725
|
if (!stat2.isFile() || stat2.size > 256 * 1024) return null;
|
|
3727
|
-
const text =
|
|
3726
|
+
const text = fs12.readFileSync(abs, "utf8");
|
|
3728
3727
|
const tokens = [pkg];
|
|
3729
3728
|
if (pkg.startsWith("@")) {
|
|
3730
3729
|
const parts = pkg.split("/");
|
|
@@ -3920,7 +3919,7 @@ function hoverMarkdown(dep, contribution, state) {
|
|
|
3920
3919
|
return lines.join("\n");
|
|
3921
3920
|
}
|
|
3922
3921
|
function startLanguageServer(opts) {
|
|
3923
|
-
if (!
|
|
3922
|
+
if (!fs12.existsSync(opts.root)) {
|
|
3924
3923
|
process.stderr.write(`vg lsp: root does not exist: ${opts.root}
|
|
3925
3924
|
`);
|
|
3926
3925
|
process.exit(1);
|
|
@@ -3970,12 +3969,12 @@ function hookCommand(vgBin) {
|
|
|
3970
3969
|
return `${vgBin} hook pre-tool-use`;
|
|
3971
3970
|
}
|
|
3972
3971
|
function installClaudeHooks(root3, vgBin = "vg") {
|
|
3973
|
-
const file =
|
|
3974
|
-
const rel =
|
|
3972
|
+
const file = path45.join(root3, ".claude", "settings.json");
|
|
3973
|
+
const rel = path45.join(".claude", "settings.json");
|
|
3975
3974
|
let settings = {};
|
|
3976
|
-
if (
|
|
3975
|
+
if (fs12.existsSync(file)) {
|
|
3977
3976
|
try {
|
|
3978
|
-
const parsed = JSON.parse(
|
|
3977
|
+
const parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
3979
3978
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
3980
3979
|
return { file: rel, status: "skipped", note: "settings.json is not a JSON object \u2014 left untouched" };
|
|
3981
3980
|
}
|
|
@@ -4012,12 +4011,12 @@ function installClaudeHooks(root3, vgBin = "vg") {
|
|
|
4012
4011
|
return { file: rel, status: "written" };
|
|
4013
4012
|
}
|
|
4014
4013
|
function uninstallClaudeHooks(root3) {
|
|
4015
|
-
const file =
|
|
4016
|
-
const rel =
|
|
4017
|
-
if (!
|
|
4014
|
+
const file = path45.join(root3, ".claude", "settings.json");
|
|
4015
|
+
const rel = path45.join(".claude", "settings.json");
|
|
4016
|
+
if (!fs12.existsSync(file)) return { file: rel, status: "unchanged" };
|
|
4018
4017
|
let settings;
|
|
4019
4018
|
try {
|
|
4020
|
-
settings = JSON.parse(
|
|
4019
|
+
settings = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
4021
4020
|
} catch {
|
|
4022
4021
|
return { file: rel, status: "skipped", note: "settings.json is not parseable JSON \u2014 left untouched" };
|
|
4023
4022
|
}
|
|
@@ -4039,8 +4038,8 @@ function uninstallClaudeHooks(root3) {
|
|
|
4039
4038
|
return { file: rel, status: "written" };
|
|
4040
4039
|
}
|
|
4041
4040
|
function writeSettings(file, settings) {
|
|
4042
|
-
|
|
4043
|
-
|
|
4041
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
4042
|
+
fs12.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
4044
4043
|
`);
|
|
4045
4044
|
}
|
|
4046
4045
|
|
|
@@ -4154,189 +4153,24 @@ function resolve4(id) {
|
|
|
4154
4153
|
}
|
|
4155
4154
|
return a;
|
|
4156
4155
|
}
|
|
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
4156
|
function disabled() {
|
|
4323
4157
|
const v = process.env.VIBGRATE_NO_KERNEL;
|
|
4324
4158
|
return v === "1" || v === "true";
|
|
4325
4159
|
}
|
|
4326
4160
|
function hcsModuleDir() {
|
|
4327
|
-
return
|
|
4161
|
+
return path45.join(modulesBaseDir(), "hcs");
|
|
4328
4162
|
}
|
|
4329
4163
|
function candidatePaths() {
|
|
4330
4164
|
const custom = process.env.VIBGRATE_HCS_PATH;
|
|
4331
4165
|
if (custom) {
|
|
4332
|
-
const p =
|
|
4166
|
+
const p = path45.resolve(custom);
|
|
4333
4167
|
try {
|
|
4334
|
-
if (
|
|
4168
|
+
if (fs12.statSync(p).isDirectory()) return [path45.join(p, "index.js")];
|
|
4335
4169
|
} catch {
|
|
4336
4170
|
}
|
|
4337
4171
|
return [p];
|
|
4338
4172
|
}
|
|
4339
|
-
return [
|
|
4173
|
+
return [path45.join(hcsModuleDir(), "index.js")];
|
|
4340
4174
|
}
|
|
4341
4175
|
var cached;
|
|
4342
4176
|
function resetHcsEngineCache() {
|
|
@@ -4347,7 +4181,7 @@ async function loadHcsEngine() {
|
|
|
4347
4181
|
cached = null;
|
|
4348
4182
|
if (disabled()) return cached;
|
|
4349
4183
|
for (const p of candidatePaths()) {
|
|
4350
|
-
if (!
|
|
4184
|
+
if (!fs12.existsSync(p)) continue;
|
|
4351
4185
|
try {
|
|
4352
4186
|
const mod = await import(pathToFileURL(p).href);
|
|
4353
4187
|
const engine = await mod.createHcsEngine?.();
|
|
@@ -4514,7 +4348,7 @@ function hookContext(payloadText, root3, graphOverride) {
|
|
|
4514
4348
|
let graph;
|
|
4515
4349
|
try {
|
|
4516
4350
|
const preferred = loadGraphPreferIndex(root3, graphPath);
|
|
4517
|
-
graph = preferred ? preferred.graph : parseGraph(
|
|
4351
|
+
graph = preferred ? preferred.graph : parseGraph(fs12.readFileSync(graphPath, "utf8"));
|
|
4518
4352
|
} catch {
|
|
4519
4353
|
return null;
|
|
4520
4354
|
}
|
|
@@ -4536,7 +4370,7 @@ function registerHook(program) {
|
|
|
4536
4370
|
const global = readGlobal(this);
|
|
4537
4371
|
const root3 = rootOf(global);
|
|
4538
4372
|
try {
|
|
4539
|
-
const stdin =
|
|
4373
|
+
const stdin = fs12.readFileSync(0, "utf8");
|
|
4540
4374
|
const context = hookContext(stdin, root3, global.graph);
|
|
4541
4375
|
if (context) {
|
|
4542
4376
|
process.stdout.write(
|
|
@@ -4556,8 +4390,8 @@ function registerShare(program) {
|
|
|
4556
4390
|
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
4391
|
const global = readGlobal(this);
|
|
4558
4392
|
const root3 = rootOf(global);
|
|
4559
|
-
const gitDir =
|
|
4560
|
-
if (!
|
|
4393
|
+
const gitDir = path45.join(root3, ".git");
|
|
4394
|
+
if (!fs12.existsSync(gitDir)) {
|
|
4561
4395
|
throw new CliError("not a git repository \u2014 run `vg share` inside a git repo", ExitCode.USAGE_ERROR);
|
|
4562
4396
|
}
|
|
4563
4397
|
if (opts.undo) {
|
|
@@ -4578,23 +4412,23 @@ function registerShare(program) {
|
|
|
4578
4412
|
applyGlobalOptions(cmd);
|
|
4579
4413
|
}
|
|
4580
4414
|
function writeVibgrateGitignore(root3, reports) {
|
|
4581
|
-
const dir =
|
|
4582
|
-
|
|
4415
|
+
const dir = path45.join(root3, ".vibgrate");
|
|
4416
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
4583
4417
|
const lines = ["# Managed by `vg share` \u2014 keep graph.json committed, ignore the rest", "cache/", "facts.jsonl", "graph.snap"];
|
|
4584
4418
|
if (!reports) lines.push("graph.html", "GRAPH_REPORT.md");
|
|
4585
|
-
|
|
4419
|
+
fs12.writeFileSync(path45.join(dir, ".gitignore"), `${lines.join("\n")}
|
|
4586
4420
|
`);
|
|
4587
4421
|
}
|
|
4588
4422
|
function writeGitAttributes(root3) {
|
|
4589
|
-
const file =
|
|
4423
|
+
const file = path45.join(root3, ".gitattributes");
|
|
4590
4424
|
const line = ".vibgrate/graph.json merge=vg";
|
|
4591
|
-
let content =
|
|
4425
|
+
let content = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : "";
|
|
4592
4426
|
if (!content.split("\n").some((l) => l.trim() === line)) {
|
|
4593
4427
|
content = content.length ? `${content.replace(/\s*$/, "")}
|
|
4594
4428
|
${line}
|
|
4595
4429
|
` : `${line}
|
|
4596
4430
|
`;
|
|
4597
|
-
|
|
4431
|
+
fs12.writeFileSync(file, content);
|
|
4598
4432
|
}
|
|
4599
4433
|
}
|
|
4600
4434
|
function configureMergeDriver(root3) {
|
|
@@ -4603,8 +4437,8 @@ function configureMergeDriver(root3) {
|
|
|
4603
4437
|
}
|
|
4604
4438
|
function installPreCommitHook(root3) {
|
|
4605
4439
|
const hooksDir = hookDir(root3);
|
|
4606
|
-
|
|
4607
|
-
const file =
|
|
4440
|
+
fs12.mkdirSync(hooksDir, { recursive: true });
|
|
4441
|
+
const file = path45.join(hooksDir, "pre-commit");
|
|
4608
4442
|
const block = [
|
|
4609
4443
|
HOOK_BEGIN,
|
|
4610
4444
|
"if command -v vg >/dev/null 2>&1; then",
|
|
@@ -4613,7 +4447,7 @@ function installPreCommitHook(root3) {
|
|
|
4613
4447
|
"fi",
|
|
4614
4448
|
HOOK_END
|
|
4615
4449
|
].join("\n");
|
|
4616
|
-
let content =
|
|
4450
|
+
let content = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : "#!/bin/sh\n";
|
|
4617
4451
|
const re = new RegExp(`${escapeRe(HOOK_BEGIN)}[\\s\\S]*?${escapeRe(HOOK_END)}`);
|
|
4618
4452
|
if (re.test(content)) content = content.replace(re, block);
|
|
4619
4453
|
else content = `${content.replace(/\s*$/, "")}
|
|
@@ -4622,21 +4456,21 @@ ${block}
|
|
|
4622
4456
|
`;
|
|
4623
4457
|
if (!content.startsWith("#!")) content = `#!/bin/sh
|
|
4624
4458
|
${content}`;
|
|
4625
|
-
|
|
4626
|
-
|
|
4459
|
+
fs12.writeFileSync(file, content);
|
|
4460
|
+
fs12.chmodSync(file, 493);
|
|
4627
4461
|
}
|
|
4628
4462
|
function undo(root3) {
|
|
4629
|
-
const hookFile =
|
|
4630
|
-
if (
|
|
4463
|
+
const hookFile = path45.join(hookDir(root3), "pre-commit");
|
|
4464
|
+
if (fs12.existsSync(hookFile)) {
|
|
4631
4465
|
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
|
|
4466
|
+
const next2 = fs12.readFileSync(hookFile, "utf8").replace(re, "\n");
|
|
4467
|
+
if (next2.trim() === "#!/bin/sh") fs12.rmSync(hookFile);
|
|
4468
|
+
else fs12.writeFileSync(hookFile, next2);
|
|
4635
4469
|
}
|
|
4636
|
-
const attr =
|
|
4637
|
-
if (
|
|
4638
|
-
const next2 =
|
|
4639
|
-
|
|
4470
|
+
const attr = path45.join(root3, ".gitattributes");
|
|
4471
|
+
if (fs12.existsSync(attr)) {
|
|
4472
|
+
const next2 = fs12.readFileSync(attr, "utf8").split("\n").filter((l) => l.trim() !== ".vibgrate/graph.json merge=vg").join("\n");
|
|
4473
|
+
fs12.writeFileSync(attr, next2);
|
|
4640
4474
|
}
|
|
4641
4475
|
try {
|
|
4642
4476
|
git(root3, ["config", "--remove-section", "merge.vg"]);
|
|
@@ -4646,10 +4480,10 @@ function undo(root3) {
|
|
|
4646
4480
|
function hookDir(root3) {
|
|
4647
4481
|
try {
|
|
4648
4482
|
const configured = git(root3, ["config", "--get", "core.hooksPath"]).trim();
|
|
4649
|
-
if (configured) return
|
|
4483
|
+
if (configured) return path45.resolve(root3, configured);
|
|
4650
4484
|
} catch {
|
|
4651
4485
|
}
|
|
4652
|
-
return
|
|
4486
|
+
return path45.join(root3, ".git", "hooks");
|
|
4653
4487
|
}
|
|
4654
4488
|
function git(root3, args) {
|
|
4655
4489
|
return execFileSync("git", args, { cwd: root3, encoding: "utf8" });
|
|
@@ -4663,9 +4497,9 @@ function registerWatch(program) {
|
|
|
4663
4497
|
const global = readGlobal(this);
|
|
4664
4498
|
const root3 = rootOf(global);
|
|
4665
4499
|
const debounceMs = Math.max(50, Number(opts.debounce) || DEFAULT_DEBOUNCE_MS);
|
|
4666
|
-
const watchRoots = (paths.length ? paths : ["."]).map((p) =>
|
|
4500
|
+
const watchRoots = (paths.length ? paths : ["."]).map((p) => path45.resolve(root3, p));
|
|
4667
4501
|
for (const w of watchRoots) {
|
|
4668
|
-
if (!
|
|
4502
|
+
if (!fs12.existsSync(w)) {
|
|
4669
4503
|
throw new CliError(`watch path not found: ${w}`, ExitCode.USAGE_ERROR);
|
|
4670
4504
|
}
|
|
4671
4505
|
}
|
|
@@ -4718,7 +4552,7 @@ function registerWatch(program) {
|
|
|
4718
4552
|
const watchers = [];
|
|
4719
4553
|
for (const w of watchRoots) {
|
|
4720
4554
|
try {
|
|
4721
|
-
const watcher =
|
|
4555
|
+
const watcher = fs12.watch(w, { recursive: true }, (_event, filename) => {
|
|
4722
4556
|
if (!filename) {
|
|
4723
4557
|
schedule("change");
|
|
4724
4558
|
return;
|
|
@@ -4731,7 +4565,7 @@ function registerWatch(program) {
|
|
|
4731
4565
|
throw new CliError(`cannot watch ${w}: ${err.message}`, ExitCode.ERROR);
|
|
4732
4566
|
}
|
|
4733
4567
|
}
|
|
4734
|
-
info(c.dim(`vg watch \xB7 watching ${watchRoots.map((p) =>
|
|
4568
|
+
info(c.dim(`vg watch \xB7 watching ${watchRoots.map((p) => path45.relative(root3, p) || ".").join(", ")} (debounce ${debounceMs}ms) \xB7 Ctrl+C to stop`));
|
|
4735
4569
|
await new Promise((resolve23) => {
|
|
4736
4570
|
const stop = () => {
|
|
4737
4571
|
for (const w of watchers) w.close();
|
|
@@ -5064,10 +4898,10 @@ function normalizeStandards(raw) {
|
|
|
5064
4898
|
}
|
|
5065
4899
|
function loadStandards(root3) {
|
|
5066
4900
|
for (const rel of STANDARDS_FILES) {
|
|
5067
|
-
const p =
|
|
4901
|
+
const p = path45__default.join(root3, rel);
|
|
5068
4902
|
let text;
|
|
5069
4903
|
try {
|
|
5070
|
-
text =
|
|
4904
|
+
text = fs12__default.readFileSync(p, "utf8");
|
|
5071
4905
|
} catch {
|
|
5072
4906
|
continue;
|
|
5073
4907
|
}
|
|
@@ -5785,8 +5619,8 @@ async function runHostBench(options = {}) {
|
|
|
5785
5619
|
}
|
|
5786
5620
|
async function runArmSimulate(input) {
|
|
5787
5621
|
const { arm, lib, modelPath, turns, trie, env, live } = input;
|
|
5788
|
-
const
|
|
5789
|
-
const session = await acquireHostSession(lib,
|
|
5622
|
+
const path47 = `${modelPath}#${arm.id}`;
|
|
5623
|
+
const session = await acquireHostSession(lib, path47);
|
|
5790
5624
|
const system = "You are a coding agent with a Task Capsule.";
|
|
5791
5625
|
const capsule = "function readConfig(): Config { return load(); }";
|
|
5792
5626
|
let last = null;
|
|
@@ -6998,7 +6832,7 @@ function registerModels(program) {
|
|
|
6998
6832
|
);
|
|
6999
6833
|
}
|
|
7000
6834
|
} else {
|
|
7001
|
-
if (!target.path || !
|
|
6835
|
+
if (!target.path || !fs12.existsSync(target.path)) {
|
|
7002
6836
|
throw new CliError(
|
|
7003
6837
|
`model file not found at ${target.path || "(unknown path)"} \u2014 it may already be removed.`,
|
|
7004
6838
|
ExitCode.NOT_FOUND
|
|
@@ -7012,7 +6846,7 @@ function registerModels(program) {
|
|
|
7012
6846
|
}
|
|
7013
6847
|
if (!global.json) info(c.dim(` $ rm ${target.path}`));
|
|
7014
6848
|
try {
|
|
7015
|
-
|
|
6849
|
+
fs12.unlinkSync(target.path);
|
|
7016
6850
|
} catch (e) {
|
|
7017
6851
|
const msg = e instanceof Error ? e.message : String(e);
|
|
7018
6852
|
throw new CliError(`could not delete ${target.path}: ${msg}`, ExitCode.ERROR);
|
|
@@ -7150,9 +6984,9 @@ function registerModels(program) {
|
|
|
7150
6984
|
}
|
|
7151
6985
|
});
|
|
7152
6986
|
if (opts.out) {
|
|
7153
|
-
const outPath =
|
|
7154
|
-
|
|
7155
|
-
|
|
6987
|
+
const outPath = path45.resolve(opts.out);
|
|
6988
|
+
fs12.mkdirSync(path45.dirname(outPath), { recursive: true });
|
|
6989
|
+
fs12.writeFileSync(outPath, `${JSON.stringify(report, null, 2)}
|
|
7156
6990
|
`);
|
|
7157
6991
|
if (!global.json) info(c.dim(` wrote ${outPath}`));
|
|
7158
6992
|
}
|
|
@@ -7301,14 +7135,14 @@ function resolveUninstallTarget(name, runtimeOpt) {
|
|
|
7301
7135
|
}
|
|
7302
7136
|
return exact[0];
|
|
7303
7137
|
}
|
|
7304
|
-
const base =
|
|
7138
|
+
const base = path45.basename(wantLc);
|
|
7305
7139
|
const soft = fleet.filter((m) => {
|
|
7306
7140
|
const n = m.name.toLowerCase();
|
|
7307
|
-
return n === base || n.endsWith("/" + base) || n.endsWith(wantLc) ||
|
|
7141
|
+
return n === base || n.endsWith("/" + base) || n.endsWith(wantLc) || path45.basename(n) === base;
|
|
7308
7142
|
});
|
|
7309
7143
|
if (soft.length === 1) return soft[0];
|
|
7310
7144
|
if (soft.length > 1) {
|
|
7311
|
-
const baseHits = soft.filter((m) =>
|
|
7145
|
+
const baseHits = soft.filter((m) => path45.basename(m.name).toLowerCase() === base);
|
|
7312
7146
|
const pool = baseHits.length ? baseHits : soft;
|
|
7313
7147
|
const order = ["ollama", "gguf", "lm-studio"];
|
|
7314
7148
|
for (const rt of order) {
|
|
@@ -7346,11 +7180,11 @@ function printBackends(backends) {
|
|
|
7346
7180
|
}
|
|
7347
7181
|
}
|
|
7348
7182
|
function codeConfigPath(root3) {
|
|
7349
|
-
return
|
|
7183
|
+
return path45.join(root3, ".vibgrate", "code.json");
|
|
7350
7184
|
}
|
|
7351
7185
|
function loadCodeConfig(root3) {
|
|
7352
7186
|
try {
|
|
7353
|
-
const raw = JSON.parse(
|
|
7187
|
+
const raw = JSON.parse(fs12.readFileSync(codeConfigPath(root3), "utf8"));
|
|
7354
7188
|
return sanitize(raw);
|
|
7355
7189
|
} catch {
|
|
7356
7190
|
return {};
|
|
@@ -7417,7 +7251,7 @@ function contextBudgetFor(config, modelContextWindow) {
|
|
|
7417
7251
|
var MCP_CONFIG_FILES = [".cursor/mcp.json", ".vscode/mcp.json", ".mcp.json"];
|
|
7418
7252
|
function readMcpServersFile(file) {
|
|
7419
7253
|
try {
|
|
7420
|
-
const raw = JSON.parse(
|
|
7254
|
+
const raw = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
7421
7255
|
const map = raw.mcpServers ?? raw.servers;
|
|
7422
7256
|
return map && typeof map === "object" ? parseMcpServers(map) : {};
|
|
7423
7257
|
} catch {
|
|
@@ -7428,7 +7262,7 @@ function discoverMcpServers(root3, ownServers) {
|
|
|
7428
7262
|
const servers = {};
|
|
7429
7263
|
const sources = [];
|
|
7430
7264
|
for (const rel of MCP_CONFIG_FILES) {
|
|
7431
|
-
const found = readMcpServersFile(
|
|
7265
|
+
const found = readMcpServersFile(path45.join(root3, rel));
|
|
7432
7266
|
const names = Object.keys(found);
|
|
7433
7267
|
if (names.length) {
|
|
7434
7268
|
sources.push(rel);
|
|
@@ -7493,7 +7327,7 @@ function registerCode(program) {
|
|
|
7493
7327
|
if (opts.worktreeDiff || opts.worktreeApply || opts.worktreeRemove) {
|
|
7494
7328
|
const wt = await import('./worktree-session-D575IQWM.js');
|
|
7495
7329
|
const child = await import('child_process');
|
|
7496
|
-
const
|
|
7330
|
+
const os6 = await import('os');
|
|
7497
7331
|
const pathMod = await import('path');
|
|
7498
7332
|
const root4 = rootOf(global);
|
|
7499
7333
|
const gitRunner = (gitArgs, gitEnv) => {
|
|
@@ -7542,10 +7376,10 @@ function registerCode(program) {
|
|
|
7542
7376
|
return;
|
|
7543
7377
|
}
|
|
7544
7378
|
const patchFile = pathMod.join(
|
|
7545
|
-
|
|
7379
|
+
fs12.mkdtempSync(pathMod.join(os6.tmpdir(), "vg-wt-")),
|
|
7546
7380
|
"delta.patch"
|
|
7547
7381
|
);
|
|
7548
|
-
|
|
7382
|
+
fs12.writeFileSync(patchFile, diff2.patch);
|
|
7549
7383
|
const outcome = wt.applyWorktreePatch(gitRunner, root4, patchFile, diff2.files);
|
|
7550
7384
|
emitLine({ event: "worktree-applied", id: target.id, ...outcome });
|
|
7551
7385
|
if (!opts.streamJson && !global.json) {
|
|
@@ -7611,7 +7445,7 @@ function registerCode(program) {
|
|
|
7611
7445
|
try {
|
|
7612
7446
|
const { parseMode: parseMode2, resolveMode: resolveMode2, readOrchestratorState: readOrchestratorState2, activePin: activePin2 } = await import('./model-orchestrator-X3NE3Y2G.js');
|
|
7613
7447
|
const { gatherSystemMemory: gatherSystemMemory2 } = await import('./local-runtime-GA43KYS5.js');
|
|
7614
|
-
const { loadGraph: loadGraph2 } = await import('./load-
|
|
7448
|
+
const { loadGraph: loadGraph2 } = await import('./load-LT6R73IZ.js');
|
|
7615
7449
|
const state = readOrchestratorState2();
|
|
7616
7450
|
const mode = parseMode2(modeFlag) ?? state.defaultMode ?? void 0;
|
|
7617
7451
|
const pin = mode ? activePin2(mode, state) : null;
|
|
@@ -7696,7 +7530,7 @@ function registerCode(program) {
|
|
|
7696
7530
|
if (!(process.stdin.isTTY && process.stdout.isTTY)) {
|
|
7697
7531
|
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
7532
|
}
|
|
7699
|
-
const { runInteractive } = await import('./interactive-
|
|
7533
|
+
const { runInteractive } = await import('./interactive-YJ37ZWTA.js');
|
|
7700
7534
|
await runInteractive(
|
|
7701
7535
|
rootOf(global),
|
|
7702
7536
|
global,
|
|
@@ -7726,7 +7560,7 @@ function registerCode(program) {
|
|
|
7726
7560
|
}
|
|
7727
7561
|
if (!instruction && !stdinFirstTurn) throw usageError('say what to change, e.g. `vg code "add a --timeout flag to the scan command"`');
|
|
7728
7562
|
{
|
|
7729
|
-
const { ensureCodeMap } = await import('./ensure-map-
|
|
7563
|
+
const { ensureCodeMap } = await import('./ensure-map-YL5NR6UH.js');
|
|
7730
7564
|
const mapRoot = rootOf(global);
|
|
7731
7565
|
try {
|
|
7732
7566
|
await ensureCodeMap(mapRoot, global, {
|
|
@@ -7763,7 +7597,7 @@ function registerCode(program) {
|
|
|
7763
7597
|
let mockReply;
|
|
7764
7598
|
if (opts.mock) {
|
|
7765
7599
|
try {
|
|
7766
|
-
mockReply =
|
|
7600
|
+
mockReply = fs12.readFileSync(opts.mock, "utf8");
|
|
7767
7601
|
} catch {
|
|
7768
7602
|
throw new CliError(`couldn't read the --mock file: ${opts.mock}`, ExitCode.USAGE_ERROR);
|
|
7769
7603
|
}
|
|
@@ -7811,20 +7645,20 @@ function registerCode(program) {
|
|
|
7811
7645
|
process.stdout.write(JSON.stringify(line) + "\n");
|
|
7812
7646
|
};
|
|
7813
7647
|
try {
|
|
7814
|
-
const { RunOutcomeRecorder, newOneShotRunId, turnRunId } = await import('./run-outcome-
|
|
7648
|
+
const { RunOutcomeRecorder, newOneShotRunId, turnRunId } = await import('./run-outcome-YQBPYNEY.js');
|
|
7815
7649
|
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-
|
|
7650
|
+
const { runCodeStreamJson, parseHostMessage } = await import('./stream-json-VJ2O52CR.js');
|
|
7651
|
+
const { nodeCodeFs } = await import('./session-3FLVZRMM.js');
|
|
7818
7652
|
const readline6 = await import('readline');
|
|
7819
7653
|
const child = await import('child_process');
|
|
7820
7654
|
const { loadOrDiscoverFederation } = await import('./federation-M4ZNXOPX.js');
|
|
7821
7655
|
const { resolveExecutionEnv } = await import('./execution-env-4MS5AYAN.js');
|
|
7822
7656
|
const { resolveModelExecutionProfile, mergeModelExecutionProfile } = await import('./model-execution-profile-ELWF3Z6H.js');
|
|
7823
|
-
const { startCodeRuntimeSession } = await import('./runtime-session-
|
|
7824
|
-
const { resolveGraphBackend } = await import('./graph-backend-
|
|
7657
|
+
const { startCodeRuntimeSession } = await import('./runtime-session-JSH5UL7Z.js');
|
|
7658
|
+
const { resolveGraphBackend } = await import('./graph-backend-LEPXFPXQ.js');
|
|
7825
7659
|
const { detectGitRef } = await import('./git-ref-LMT3EXYY.js');
|
|
7826
7660
|
const { repositoryIdFromRoot } = await import('./paths-RVK6FKRN.js');
|
|
7827
|
-
const { vgdRequest } = await import('./vgd-
|
|
7661
|
+
const { vgdRequest } = await import('./vgd-XFT574U6.js');
|
|
7828
7662
|
const federation = loadOrDiscoverFederation(root3);
|
|
7829
7663
|
const modelProfile = mergeModelExecutionProfile(
|
|
7830
7664
|
resolveModelExecutionProfile({
|
|
@@ -7882,7 +7716,7 @@ ${res.stderr}` : ""),
|
|
|
7882
7716
|
exitCode: res.status ?? 1
|
|
7883
7717
|
};
|
|
7884
7718
|
};
|
|
7885
|
-
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-
|
|
7719
|
+
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-UUMEOJSO.js');
|
|
7886
7720
|
const vgBuiltin = createVgBuiltinMcpTools({
|
|
7887
7721
|
getGraph: () => graph,
|
|
7888
7722
|
root: root3,
|
|
@@ -7903,10 +7737,10 @@ ${res.stderr}` : ""),
|
|
|
7903
7737
|
}
|
|
7904
7738
|
const externalTools = mergeExternalToolsets(vgBuiltin, projectMcp);
|
|
7905
7739
|
const { createCheckpoint } = await import('./checkpoint-UYMYMMQO.js');
|
|
7906
|
-
const
|
|
7740
|
+
const os6 = await import('os');
|
|
7907
7741
|
const pathMod = await import('path');
|
|
7908
7742
|
const checkpointIndex = pathMod.join(
|
|
7909
|
-
|
|
7743
|
+
fs12.mkdtempSync(pathMod.join(os6.tmpdir(), "vg-code-cp-")),
|
|
7910
7744
|
"index"
|
|
7911
7745
|
);
|
|
7912
7746
|
const gitRunner = (gitArgs, gitEnv) => {
|
|
@@ -7927,7 +7761,7 @@ ${res.stderr}` : ""),
|
|
|
7927
7761
|
files,
|
|
7928
7762
|
indexFile: checkpointIndex
|
|
7929
7763
|
});
|
|
7930
|
-
const { loadApprovalRules, addApprovalRule, ruleForAction, ruleLabel } = await import('./approvals-
|
|
7764
|
+
const { loadApprovalRules, addApprovalRule, ruleForAction, ruleLabel } = await import('./approvals-5UBLBNJF.js');
|
|
7931
7765
|
const { loadProjectRules, nodeRulesReader } = await import('./rules-ASYEUNB5.js');
|
|
7932
7766
|
const projectRules = loadProjectRules(nodeRulesReader(root3));
|
|
7933
7767
|
if (projectRules.sources.length && !global.quiet) {
|
|
@@ -7985,8 +7819,8 @@ ${res.stderr}` : ""),
|
|
|
7985
7819
|
};
|
|
7986
7820
|
try {
|
|
7987
7821
|
if (opts.session) {
|
|
7988
|
-
const { runCodeStreamJsonSession, STREAM_JSON_PROTOCOL_VERSION } = await import('./stream-json-
|
|
7989
|
-
const { runAgent: runAgent2 } = await import('./agent-
|
|
7822
|
+
const { runCodeStreamJsonSession, STREAM_JSON_PROTOCOL_VERSION } = await import('./stream-json-VJ2O52CR.js');
|
|
7823
|
+
const { runAgent: runAgent2 } = await import('./agent-6SJVWFPV.js');
|
|
7990
7824
|
const {
|
|
7991
7825
|
condenseSession,
|
|
7992
7826
|
loadLatestSession,
|
|
@@ -7997,7 +7831,7 @@ ${res.stderr}` : ""),
|
|
|
7997
7831
|
sessionsDir,
|
|
7998
7832
|
summarizeSession
|
|
7999
7833
|
} = await import('./session-store-AQUORKWB.js');
|
|
8000
|
-
const { VERSION: VERSION2 } = await import('./version-
|
|
7834
|
+
const { VERSION: VERSION2 } = await import('./version-VUTM46C5.js');
|
|
8001
7835
|
const resumedRecord = typeof opts.continue === "string" ? loadSession(mainRoot, opts.continue) : opts.continue ? loadLatestSession(mainRoot) : void 0;
|
|
8002
7836
|
if (typeof opts.continue === "string" && !resumedRecord) {
|
|
8003
7837
|
emitStream({
|
|
@@ -8209,8 +8043,8 @@ ${res.stderr}` : ""),
|
|
|
8209
8043
|
if (!autonomous && !tty) {
|
|
8210
8044
|
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
8045
|
}
|
|
8212
|
-
const { agentTask } = await import('./interactive-
|
|
8213
|
-
const { nodeCodeFs } = await import('./session-
|
|
8046
|
+
const { agentTask } = await import('./interactive-YJ37ZWTA.js');
|
|
8047
|
+
const { nodeCodeFs } = await import('./session-3FLVZRMM.js');
|
|
8214
8048
|
const { TtyPrompter } = await import('./ui-K7D3BCHD.js');
|
|
8215
8049
|
let priorSummary;
|
|
8216
8050
|
let priorInstruction;
|
|
@@ -8225,7 +8059,7 @@ ${res.stderr}` : ""),
|
|
|
8225
8059
|
}
|
|
8226
8060
|
}
|
|
8227
8061
|
const prompter = tty ? new TtyPrompter() : void 0;
|
|
8228
|
-
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-
|
|
8062
|
+
const { createVgBuiltinMcpTools, mergeExternalToolsets } = await import('./vg-mcp-bridge-UUMEOJSO.js');
|
|
8229
8063
|
const vgBuiltin = createVgBuiltinMcpTools({
|
|
8230
8064
|
getGraph: () => graph,
|
|
8231
8065
|
root: root3,
|
|
@@ -8249,11 +8083,11 @@ ${res.stderr}` : ""),
|
|
|
8249
8083
|
const { loadFederation } = await import('./federation-M4ZNXOPX.js');
|
|
8250
8084
|
const { resolveExecutionEnv } = await import('./execution-env-4MS5AYAN.js');
|
|
8251
8085
|
const { resolveModelExecutionProfile, mergeModelExecutionProfile } = await import('./model-execution-profile-ELWF3Z6H.js');
|
|
8252
|
-
const { startCodeRuntimeSession } = await import('./runtime-session-
|
|
8253
|
-
const { resolveGraphBackend } = await import('./graph-backend-
|
|
8086
|
+
const { startCodeRuntimeSession } = await import('./runtime-session-JSH5UL7Z.js');
|
|
8087
|
+
const { resolveGraphBackend } = await import('./graph-backend-LEPXFPXQ.js');
|
|
8254
8088
|
const { detectGitRef } = await import('./git-ref-LMT3EXYY.js');
|
|
8255
8089
|
const { repositoryIdFromRoot } = await import('./paths-RVK6FKRN.js');
|
|
8256
|
-
const { vgdRequest } = await import('./vgd-
|
|
8090
|
+
const { vgdRequest } = await import('./vgd-XFT574U6.js');
|
|
8257
8091
|
const federation = loadFederation(root3);
|
|
8258
8092
|
const modelProfile = mergeModelExecutionProfile(
|
|
8259
8093
|
resolveModelExecutionProfile({
|
|
@@ -8347,7 +8181,7 @@ ${res.stderr}` : ""),
|
|
|
8347
8181
|
attribution: { client: "vg-code", provider: providerSlug, model: primary?.model }
|
|
8348
8182
|
});
|
|
8349
8183
|
if (opts.out) {
|
|
8350
|
-
|
|
8184
|
+
fs12.writeFileSync(opts.out, JSON.stringify(result, null, 2) + "\n");
|
|
8351
8185
|
}
|
|
8352
8186
|
if (global.json) {
|
|
8353
8187
|
json(result);
|
|
@@ -8561,7 +8395,7 @@ async function addCmd(root3, rest, opts, asJson) {
|
|
|
8561
8395
|
}
|
|
8562
8396
|
function readPackageVersion(root3) {
|
|
8563
8397
|
try {
|
|
8564
|
-
const pkg = JSON.parse(
|
|
8398
|
+
const pkg = JSON.parse(fs12__default.readFileSync(path45__default.join(root3, "package.json"), "utf8"));
|
|
8565
8399
|
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
8566
8400
|
} catch {
|
|
8567
8401
|
return void 0;
|
|
@@ -8569,7 +8403,7 @@ function readPackageVersion(root3) {
|
|
|
8569
8403
|
}
|
|
8570
8404
|
function readOptionalFile(p) {
|
|
8571
8405
|
try {
|
|
8572
|
-
const t =
|
|
8406
|
+
const t = fs12__default.readFileSync(p, "utf8");
|
|
8573
8407
|
return t.trim() ? t : void 0;
|
|
8574
8408
|
} catch {
|
|
8575
8409
|
return void 0;
|
|
@@ -8584,8 +8418,8 @@ async function publishCmd(root3, rest, opts, global, asJson) {
|
|
|
8584
8418
|
if (!parsed) throw new CliError("publishing a private library requires a DSN \u2014 run `vibgrate login` or set VIBGRATE_DSN", ExitCode.USAGE_ERROR);
|
|
8585
8419
|
const version = (opts.version || readPackageVersion(root3) || "").trim();
|
|
8586
8420
|
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(
|
|
8421
|
+
const readme = readOptionalFile(opts.readme ? path45__default.resolve(opts.readme) : path45__default.join(root3, "README.md"));
|
|
8422
|
+
const dts = opts.dts ? readOptionalFile(path45__default.resolve(opts.dts)) : void 0;
|
|
8589
8423
|
if (!readme && !dts) throw usageError("nothing to publish \u2014 no README.md found and no --dts given");
|
|
8590
8424
|
const result = await publishPrivateLibrary(
|
|
8591
8425
|
{ name, version, readme, dts, language: opts.language },
|
|
@@ -8717,8 +8551,8 @@ function registerExport(program) {
|
|
|
8717
8551
|
out(content.trimEnd());
|
|
8718
8552
|
return;
|
|
8719
8553
|
}
|
|
8720
|
-
|
|
8721
|
-
|
|
8554
|
+
fs12.mkdirSync(path45.dirname(path45.resolve(file)), { recursive: true });
|
|
8555
|
+
fs12.writeFileSync(file, content);
|
|
8722
8556
|
info(`${c.green("\u2714")} wrote ${file} ${c.dim(`(${format})`)}`);
|
|
8723
8557
|
});
|
|
8724
8558
|
applyGlobalOptions(cmd);
|
|
@@ -8728,49 +8562,49 @@ function detectFormat(file) {
|
|
|
8728
8562
|
if (lower.endsWith(".cdx.json")) return "cyclonedx";
|
|
8729
8563
|
if (lower.endsWith(".spdx.json")) return "spdx";
|
|
8730
8564
|
if (file === "-") return "json";
|
|
8731
|
-
return formatForExt(
|
|
8565
|
+
return formatForExt(path45.extname(file));
|
|
8732
8566
|
}
|
|
8733
8567
|
function registerBundle(program) {
|
|
8734
8568
|
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
8569
|
const global = readGlobal(this);
|
|
8736
8570
|
const root3 = rootOf(global);
|
|
8737
|
-
const outDir =
|
|
8571
|
+
const outDir = path45.resolve(root3, opts.out ?? "vg-bundle");
|
|
8738
8572
|
let grammarFiles;
|
|
8739
8573
|
try {
|
|
8740
8574
|
grammarFiles = resolvedGrammarFiles();
|
|
8741
8575
|
} catch {
|
|
8742
8576
|
throw new CliError("no grammars found to bundle (run a build first)", ExitCode.ERROR);
|
|
8743
8577
|
}
|
|
8744
|
-
|
|
8578
|
+
fs12.mkdirSync(path45.join(outDir, "grammars"), { recursive: true });
|
|
8745
8579
|
let grammarCount = 0;
|
|
8746
8580
|
for (const { fileName, absPath } of grammarFiles) {
|
|
8747
|
-
|
|
8581
|
+
fs12.copyFileSync(absPath, path45.join(outDir, "grammars", fileName));
|
|
8748
8582
|
grammarCount++;
|
|
8749
8583
|
}
|
|
8750
8584
|
for (const id of Object.keys(TOOLCHAIN_GRAMMARS).sort()) {
|
|
8751
8585
|
const absPath = resolveToolchainGrammar(id);
|
|
8752
8586
|
if (!absPath) continue;
|
|
8753
|
-
|
|
8587
|
+
fs12.copyFileSync(absPath, path45.join(outDir, "grammars", path45.basename(absPath)));
|
|
8754
8588
|
grammarCount++;
|
|
8755
8589
|
}
|
|
8756
8590
|
const included = [`grammars/ (${grammarCount} .wasm)`];
|
|
8757
8591
|
const graphSrc = resolveGraphPath(root3, global.graph);
|
|
8758
|
-
if (
|
|
8759
|
-
|
|
8592
|
+
if (fs12.existsSync(graphSrc)) {
|
|
8593
|
+
fs12.copyFileSync(graphSrc, path45.join(outDir, "graph.json"));
|
|
8760
8594
|
included.push("graph.json");
|
|
8761
8595
|
} else {
|
|
8762
8596
|
const graph = loadGraphFileWithSnapshot(graphSrc);
|
|
8763
8597
|
if (graph) {
|
|
8764
|
-
|
|
8598
|
+
fs12.writeFileSync(path45.join(outDir, "graph.json"), serializeGraph(graph));
|
|
8765
8599
|
included.push("graph.json");
|
|
8766
8600
|
}
|
|
8767
8601
|
}
|
|
8768
8602
|
const cat = catalogPath(root3);
|
|
8769
|
-
if (
|
|
8770
|
-
|
|
8603
|
+
if (fs12.existsSync(cat)) {
|
|
8604
|
+
fs12.copyFileSync(cat, path45.join(outDir, "vibgrate.lib.json"));
|
|
8771
8605
|
included.push("vibgrate.lib.json");
|
|
8772
|
-
if (
|
|
8773
|
-
|
|
8606
|
+
if (fs12.existsSync(libDir(root3))) {
|
|
8607
|
+
fs12.cpSync(libDir(root3), path45.join(outDir, "lib"), { recursive: true });
|
|
8774
8608
|
included.push("lib/");
|
|
8775
8609
|
}
|
|
8776
8610
|
}
|
|
@@ -8782,15 +8616,15 @@ function registerBundle(program) {
|
|
|
8782
8616
|
included,
|
|
8783
8617
|
usage: "Run `vg build --grammars <this dir>/grammars` to build fully offline."
|
|
8784
8618
|
};
|
|
8785
|
-
|
|
8619
|
+
fs12.writeFileSync(path45.join(outDir, "MANIFEST.json"), `${stableStringify(manifest, 2)}
|
|
8786
8620
|
`);
|
|
8787
8621
|
if (global.json) {
|
|
8788
|
-
json({ out:
|
|
8622
|
+
json({ out: path45.relative(root3, outDir), ...manifest });
|
|
8789
8623
|
return;
|
|
8790
8624
|
}
|
|
8791
|
-
info(`${c.cyan("vg bundle")} \xB7 wrote ${
|
|
8625
|
+
info(`${c.cyan("vg bundle")} \xB7 wrote ${path45.relative(root3, outDir)}/`);
|
|
8792
8626
|
for (const i of included) info(` ${c.green("\u2714")} ${i}`);
|
|
8793
|
-
info(c.dim(` offline: vg build --grammars "${
|
|
8627
|
+
info(c.dim(` offline: vg build --grammars "${path45.relative(root3, outDir)}/grammars"`));
|
|
8794
8628
|
});
|
|
8795
8629
|
applyGlobalOptions(cmd);
|
|
8796
8630
|
}
|
|
@@ -8808,7 +8642,7 @@ async function runDoctor(global) {
|
|
|
8808
8642
|
const root3 = rootOf(global);
|
|
8809
8643
|
const local = global.local === true;
|
|
8810
8644
|
const graphPath = resolveGraphPath(root3, global.graph);
|
|
8811
|
-
const configFile = CONFIG_BASENAMES.find((f) =>
|
|
8645
|
+
const configFile = CONFIG_BASENAMES.find((f) => fs12.existsSync(path45.join(root3, f))) ?? null;
|
|
8812
8646
|
const graph = loadGraph(root3, graphPath);
|
|
8813
8647
|
let staleFiles = null;
|
|
8814
8648
|
if (graph) {
|
|
@@ -8834,14 +8668,14 @@ async function runDoctor(global) {
|
|
|
8834
8668
|
root: root3,
|
|
8835
8669
|
configFile,
|
|
8836
8670
|
map: {
|
|
8837
|
-
path:
|
|
8671
|
+
path: path45.relative(root3, graphPath),
|
|
8838
8672
|
built: graph !== null,
|
|
8839
8673
|
generatedAt: graph?.generatedAt ?? null,
|
|
8840
8674
|
staleFiles
|
|
8841
8675
|
},
|
|
8842
8676
|
libCatalog: {
|
|
8843
|
-
path:
|
|
8844
|
-
present:
|
|
8677
|
+
path: path45.relative(root3, catalogPath(root3)),
|
|
8678
|
+
present: fs12.existsSync(catalogPath(root3)),
|
|
8845
8679
|
libraries: libCount
|
|
8846
8680
|
},
|
|
8847
8681
|
credentials: creds,
|
|
@@ -8898,7 +8732,7 @@ async function runDoctor(global) {
|
|
|
8898
8732
|
);
|
|
8899
8733
|
info(
|
|
8900
8734
|
` host pool ${li.hostPool.size} warm session(s)` + (li.hostPool.sessions[0] ? c.dim(
|
|
8901
|
-
` \xB7 last ${
|
|
8735
|
+
` \xB7 last ${path45.basename(li.hostPool.sessions[0].modelPath)} kv=${li.hostPool.sessions[0].kvBlocks}`
|
|
8902
8736
|
) : c.dim(" \xB7 none (load via vg code / vgd host-load)"))
|
|
8903
8737
|
);
|
|
8904
8738
|
if (li.dynamicOnToken || li.dynamicCustomSampler) {
|
|
@@ -9018,7 +8852,7 @@ function registerPolicy(program) {
|
|
|
9018
8852
|
const global = readGlobal(this);
|
|
9019
8853
|
let raw;
|
|
9020
8854
|
try {
|
|
9021
|
-
raw =
|
|
8855
|
+
raw = fs12.readFileSync(file, "utf8");
|
|
9022
8856
|
} catch {
|
|
9023
8857
|
throw new CliError(`cannot read ${file}`, ExitCode.NOT_FOUND);
|
|
9024
8858
|
}
|
|
@@ -9205,9 +9039,9 @@ async function readStdin() {
|
|
|
9205
9039
|
return Buffer.concat(chunks).toString("utf-8");
|
|
9206
9040
|
}
|
|
9207
9041
|
function readFileOrThrow(file, label) {
|
|
9208
|
-
const p =
|
|
9209
|
-
if (!
|
|
9210
|
-
return
|
|
9042
|
+
const p = path45.resolve(file);
|
|
9043
|
+
if (!fs12.existsSync(p)) throw usageError(`${label} file not found: ${p}`);
|
|
9044
|
+
return fs12.readFileSync(p, "utf-8");
|
|
9211
9045
|
}
|
|
9212
9046
|
async function readInput(file, label) {
|
|
9213
9047
|
return file ? readFileOrThrow(file, label) : readStdin();
|
|
@@ -9217,10 +9051,10 @@ function writeOutput(outFile, content) {
|
|
|
9217
9051
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
9218
9052
|
return;
|
|
9219
9053
|
}
|
|
9220
|
-
const outPath =
|
|
9221
|
-
const dir =
|
|
9222
|
-
if (!
|
|
9223
|
-
|
|
9054
|
+
const outPath = path45.resolve(outFile);
|
|
9055
|
+
const dir = path45.dirname(outPath);
|
|
9056
|
+
if (!fs12.existsSync(dir)) throw usageError(`output directory does not exist: ${dir}`);
|
|
9057
|
+
fs12.writeFileSync(outPath, content.endsWith("\n") ? content : content + "\n", "utf-8");
|
|
9224
9058
|
info(c.dim(`wrote ${outPath}`));
|
|
9225
9059
|
}
|
|
9226
9060
|
function requireChoice(value, valid2, flag) {
|
|
@@ -9253,8 +9087,8 @@ function registerHcs(program) {
|
|
|
9253
9087
|
}
|
|
9254
9088
|
const statePath = opts.previous ?? opts.out;
|
|
9255
9089
|
const useIncremental = canIncremental && statePath !== void 0;
|
|
9256
|
-
const root3 =
|
|
9257
|
-
if (!
|
|
9090
|
+
const root3 = path45.resolve(dir);
|
|
9091
|
+
if (!fs12.existsSync(root3) || !fs12.statSync(root3).isDirectory()) {
|
|
9258
9092
|
throw usageError(`not a directory: ${root3}`);
|
|
9259
9093
|
}
|
|
9260
9094
|
const supported = new Set(
|
|
@@ -9272,13 +9106,13 @@ function registerHcs(program) {
|
|
|
9272
9106
|
const walk2 = (abs, rel) => {
|
|
9273
9107
|
let entries;
|
|
9274
9108
|
try {
|
|
9275
|
-
entries =
|
|
9109
|
+
entries = fs12.readdirSync(abs, { withFileTypes: true });
|
|
9276
9110
|
} catch {
|
|
9277
9111
|
return;
|
|
9278
9112
|
}
|
|
9279
9113
|
for (const entry of entries.sort((a, b) => a.name < b.name ? -1 : 1)) {
|
|
9280
9114
|
if (entry.name.startsWith(".")) continue;
|
|
9281
|
-
const absChild =
|
|
9115
|
+
const absChild = path45.join(abs, entry.name);
|
|
9282
9116
|
const relChild = rel ? `${rel}/${entry.name}` : entry.name;
|
|
9283
9117
|
if (entry.isDirectory()) {
|
|
9284
9118
|
if (!SKIP_DIRS.has(entry.name)) walk2(absChild, relChild);
|
|
@@ -9286,11 +9120,11 @@ function registerHcs(program) {
|
|
|
9286
9120
|
}
|
|
9287
9121
|
if (!entry.isFile()) continue;
|
|
9288
9122
|
if (!opts.includeTests && TEST_PATTERNS.some((p) => p.test(relChild))) continue;
|
|
9289
|
-
const lang = extToLang.get(
|
|
9123
|
+
const lang = extToLang.get(path45.extname(entry.name).toLowerCase());
|
|
9290
9124
|
if (!lang) continue;
|
|
9291
9125
|
try {
|
|
9292
|
-
if (
|
|
9293
|
-
const content =
|
|
9126
|
+
if (fs12.statSync(absChild).size > MAX_EXTRACT_FILE_BYTES) continue;
|
|
9127
|
+
const content = fs12.readFileSync(absChild, "utf-8");
|
|
9294
9128
|
let bucket = byLanguage.get(lang);
|
|
9295
9129
|
if (!bucket) byLanguage.set(lang, bucket = []);
|
|
9296
9130
|
bucket.push({ path: relChild, content });
|
|
@@ -9320,8 +9154,8 @@ function registerHcs(program) {
|
|
|
9320
9154
|
writeOutput(opts.out, parts2.join("\n"));
|
|
9321
9155
|
return;
|
|
9322
9156
|
}
|
|
9323
|
-
const previousPath =
|
|
9324
|
-
const previousNdjson = !opts.full &&
|
|
9157
|
+
const previousPath = path45.resolve(statePath);
|
|
9158
|
+
const previousNdjson = !opts.full && fs12.existsSync(previousPath) ? fs12.readFileSync(previousPath, "utf-8") : "";
|
|
9325
9159
|
if (opts.full) info(c.dim("running a full re-extraction (--full)"));
|
|
9326
9160
|
else if (!previousNdjson) info(c.dim(`previous stream not found at ${previousPath} \u2014 running a full extraction`));
|
|
9327
9161
|
const currentFilesJson = JSON.stringify(
|
|
@@ -9425,11 +9259,11 @@ function registerHcs(program) {
|
|
|
9425
9259
|
applyGlobalOptions(cmd);
|
|
9426
9260
|
}
|
|
9427
9261
|
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 =
|
|
9262
|
+
const rootDir = path45.resolve(targetPath);
|
|
9263
|
+
const vibgrateDir2 = path45.join(rootDir, ".vibgrate");
|
|
9430
9264
|
await ensureDir(vibgrateDir2);
|
|
9431
9265
|
console.log(chalk7.green("\u2714") + ` Created ${chalk7.bold(".vibgrate/")} directory`);
|
|
9432
|
-
const configPath =
|
|
9266
|
+
const configPath = path45.join(rootDir, "vibgrate.config.ts");
|
|
9433
9267
|
if (await pathExists(configPath)) {
|
|
9434
9268
|
console.log(chalk7.dim(" vibgrate.config.ts already exists, skipping"));
|
|
9435
9269
|
} else {
|
|
@@ -9437,7 +9271,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
|
|
|
9437
9271
|
console.log(chalk7.green("\u2714") + ` Created ${chalk7.bold("vibgrate.config.ts")}`);
|
|
9438
9272
|
}
|
|
9439
9273
|
if (opts.baseline) {
|
|
9440
|
-
const { runBaseline } = await import('./baseline-
|
|
9274
|
+
const { runBaseline } = await import('./baseline-HPXACNFU.js');
|
|
9441
9275
|
await runBaseline(rootDir);
|
|
9442
9276
|
}
|
|
9443
9277
|
console.log("");
|
|
@@ -9540,7 +9374,7 @@ function collectPackageImports(graph, ecosystem, pkg) {
|
|
|
9540
9374
|
};
|
|
9541
9375
|
}
|
|
9542
9376
|
async function firstReferenceLine(rootDir, relFile, identifier, readFile3) {
|
|
9543
|
-
const content = await readFile3(
|
|
9377
|
+
const content = await readFile3(path45.join(rootDir, relFile));
|
|
9544
9378
|
if (!content) return null;
|
|
9545
9379
|
const escaped = identifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9546
9380
|
const re = new RegExp(`\\b${escaped}\\b`);
|
|
@@ -9578,9 +9412,9 @@ function sitesFromImportFiles(files, limit = 10) {
|
|
|
9578
9412
|
}
|
|
9579
9413
|
async function defaultReadFile(absPath) {
|
|
9580
9414
|
try {
|
|
9581
|
-
const stat2 = await
|
|
9415
|
+
const stat2 = await fs26.stat(absPath);
|
|
9582
9416
|
if (!stat2.isFile() || stat2.size > MAX_FILE_BYTES) return null;
|
|
9583
|
-
return await
|
|
9417
|
+
return await fs26.readFile(absPath, "utf8");
|
|
9584
9418
|
} catch {
|
|
9585
9419
|
return null;
|
|
9586
9420
|
}
|
|
@@ -9776,7 +9610,7 @@ var AI_ASSISTANT_DETECTORS = [
|
|
|
9776
9610
|
async function detectAiAssistant(rootDir) {
|
|
9777
9611
|
for (const detector of AI_ASSISTANT_DETECTORS) {
|
|
9778
9612
|
for (const file of detector.files) {
|
|
9779
|
-
if (await pathExists$1(
|
|
9613
|
+
if (await pathExists$1(path45.join(rootDir, file))) {
|
|
9780
9614
|
return detector.name;
|
|
9781
9615
|
}
|
|
9782
9616
|
}
|
|
@@ -9970,7 +9804,7 @@ function reportStandards(rootDir) {
|
|
|
9970
9804
|
}
|
|
9971
9805
|
async function printRuntimeSnapshot(rootDir, opts, already) {
|
|
9972
9806
|
try {
|
|
9973
|
-
const { attachVgd: attachVgd2 } = await import('./attach-
|
|
9807
|
+
const { attachVgd: attachVgd2 } = await import('./attach-PSGCCJMA.js');
|
|
9974
9808
|
const { vgdRequest } = await import('./client-P5XSRFV4.js');
|
|
9975
9809
|
const { formatSemanticProgress } = await import('./semantic-status-2JFLIQQJ.js');
|
|
9976
9810
|
let repositoryId = already?.repositoryId;
|
|
@@ -10012,7 +9846,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10012
9846
|
collectExcludes,
|
|
10013
9847
|
[]
|
|
10014
9848
|
).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 =
|
|
9849
|
+
const rootDir = path45.resolve(targetPath);
|
|
10016
9850
|
if (!await pathExists$1(rootDir)) {
|
|
10017
9851
|
console.error(chalk7.red(`Path does not exist: ${rootDir}`));
|
|
10018
9852
|
process.exit(1);
|
|
@@ -10020,7 +9854,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10020
9854
|
const hasDsn = !!resolveDsn(opts.dsn);
|
|
10021
9855
|
let willPush = !opts.offline && (opts.push || hasDsn);
|
|
10022
9856
|
const noLocalArtifacts = opts.localArtifacts === false;
|
|
10023
|
-
const isFirstRun = !await pathExists$1(
|
|
9857
|
+
const isFirstRun = !await pathExists$1(path45.join(rootDir, ".vibgrate", "scan_result.json"));
|
|
10024
9858
|
let pinnedRegion;
|
|
10025
9859
|
let planTier;
|
|
10026
9860
|
let upgradeUrl;
|
|
@@ -10179,7 +10013,7 @@ var scanCommand = new Command("scan").description("Scan a project for upgrade dr
|
|
|
10179
10013
|
const advanced = await loadAdvancedScanHook();
|
|
10180
10014
|
const artifact = await runCoreScan(rootDir, scanOpts, advanced);
|
|
10181
10015
|
if (wantGraph && builtGraph) {
|
|
10182
|
-
const { attachVgd: attachVgd2 } = await import('./attach-
|
|
10016
|
+
const { attachVgd: attachVgd2 } = await import('./attach-PSGCCJMA.js');
|
|
10183
10017
|
const { ActivityLog: ActivityLog2 } = await import('./activity-MF2GNYAI.js');
|
|
10184
10018
|
const activity = new ActivityLog2();
|
|
10185
10019
|
const attached = await activity.time(
|
|
@@ -10327,7 +10161,7 @@ var SKIP_DIRS2 = /* @__PURE__ */ new Set([
|
|
|
10327
10161
|
function scanStaleness(rootDir, artifactPath) {
|
|
10328
10162
|
let ref;
|
|
10329
10163
|
try {
|
|
10330
|
-
ref =
|
|
10164
|
+
ref = fs12.statSync(artifactPath).mtimeMs;
|
|
10331
10165
|
} catch {
|
|
10332
10166
|
return { stale: false };
|
|
10333
10167
|
}
|
|
@@ -10339,7 +10173,7 @@ function scanStaleness(rootDir, artifactPath) {
|
|
|
10339
10173
|
if (depth > 8 || scanned > MAX_ENTRIES2) return;
|
|
10340
10174
|
let entries;
|
|
10341
10175
|
try {
|
|
10342
|
-
entries =
|
|
10176
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
10343
10177
|
} catch {
|
|
10344
10178
|
return;
|
|
10345
10179
|
}
|
|
@@ -10347,20 +10181,20 @@ function scanStaleness(rootDir, artifactPath) {
|
|
|
10347
10181
|
scanned++;
|
|
10348
10182
|
if (scanned > MAX_ENTRIES2) break;
|
|
10349
10183
|
if (e.isDirectory()) {
|
|
10350
|
-
if (!SKIP_DIRS2.has(e.name) && !e.name.startsWith(".")) walk2(
|
|
10184
|
+
if (!SKIP_DIRS2.has(e.name) && !e.name.startsWith(".")) walk2(path45.join(dir, e.name), depth + 1);
|
|
10351
10185
|
continue;
|
|
10352
10186
|
}
|
|
10353
10187
|
if (!WATCHED_FILES.has(e.name) && !WATCHED_EXT.test(e.name)) continue;
|
|
10354
|
-
const abs =
|
|
10188
|
+
const abs = path45.join(dir, e.name);
|
|
10355
10189
|
let mtimeMs;
|
|
10356
10190
|
try {
|
|
10357
|
-
mtimeMs =
|
|
10191
|
+
mtimeMs = fs12.statSync(abs).mtimeMs;
|
|
10358
10192
|
} catch {
|
|
10359
10193
|
continue;
|
|
10360
10194
|
}
|
|
10361
10195
|
if (mtimeMs > newest) {
|
|
10362
10196
|
newest = mtimeMs;
|
|
10363
|
-
newestChanged =
|
|
10197
|
+
newestChanged = path45.relative(rootDir, abs) || e.name;
|
|
10364
10198
|
}
|
|
10365
10199
|
}
|
|
10366
10200
|
};
|
|
@@ -10491,7 +10325,7 @@ function analyzeTree(root3, packages) {
|
|
|
10491
10325
|
if (depth > MAX_DEPTH || filesSeen >= MAX_FILES) return;
|
|
10492
10326
|
let entries;
|
|
10493
10327
|
try {
|
|
10494
|
-
entries =
|
|
10328
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
10495
10329
|
} catch {
|
|
10496
10330
|
return;
|
|
10497
10331
|
}
|
|
@@ -10500,17 +10334,17 @@ function analyzeTree(root3, packages) {
|
|
|
10500
10334
|
if (filesSeen >= MAX_FILES) return;
|
|
10501
10335
|
if (entry.isDirectory()) {
|
|
10502
10336
|
if (SKIP_DIRS3.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
10503
|
-
walk2(
|
|
10337
|
+
walk2(path45.join(dir, entry.name), depth + 1);
|
|
10504
10338
|
continue;
|
|
10505
10339
|
}
|
|
10506
|
-
const fileEco = EXT_ECOSYSTEM[
|
|
10340
|
+
const fileEco = EXT_ECOSYSTEM[path45.extname(entry.name)];
|
|
10507
10341
|
if (!fileEco || fileEco === "unknown") continue;
|
|
10508
10342
|
filesSeen++;
|
|
10509
|
-
const full =
|
|
10343
|
+
const full = path45.join(dir, entry.name);
|
|
10510
10344
|
let content;
|
|
10511
10345
|
try {
|
|
10512
|
-
if (
|
|
10513
|
-
content =
|
|
10346
|
+
if (fs12.statSync(full).size > MAX_FILE_BYTES2) continue;
|
|
10347
|
+
content = fs12.readFileSync(full, "utf8");
|
|
10514
10348
|
} catch {
|
|
10515
10349
|
continue;
|
|
10516
10350
|
}
|
|
@@ -10821,7 +10655,7 @@ function applyPlan(rootDir, upgrades, opts = {}) {
|
|
|
10821
10655
|
}
|
|
10822
10656
|
const outcomes = effective.map((t) => {
|
|
10823
10657
|
const c2 = pmCommandFor(u.ecosystem, u.package, u.to, opts.packageManager, { workspaceRoot: t.isWorkspaceRoot });
|
|
10824
|
-
return { t, res: run(c2,
|
|
10658
|
+
return { t, res: run(c2, path45.join(rootDir, t.dir)) };
|
|
10825
10659
|
});
|
|
10826
10660
|
const failures = outcomes.filter((o) => !o.res.ok);
|
|
10827
10661
|
if (failures.length === 0) {
|
|
@@ -10850,8 +10684,8 @@ function applyPlan(rootDir, upgrades, opts = {}) {
|
|
|
10850
10684
|
return results;
|
|
10851
10685
|
}
|
|
10852
10686
|
var REGISTRY_URL = "https://registry.npmjs.org/@vibgrate%2fcli/latest";
|
|
10853
|
-
var CACHE_DIR =
|
|
10854
|
-
var CACHE_FILE =
|
|
10687
|
+
var CACHE_DIR = path45.join(os.homedir(), ".vibgrate");
|
|
10688
|
+
var CACHE_FILE = path45.join(CACHE_DIR, "update-check.json");
|
|
10855
10689
|
async function fetchLatestVersion() {
|
|
10856
10690
|
try {
|
|
10857
10691
|
const controller = new AbortController();
|
|
@@ -10878,8 +10712,8 @@ async function fetchLatestVersion() {
|
|
|
10878
10712
|
}
|
|
10879
10713
|
async function writeCache(data) {
|
|
10880
10714
|
try {
|
|
10881
|
-
await
|
|
10882
|
-
await
|
|
10715
|
+
await fs26.mkdir(CACHE_DIR, { recursive: true });
|
|
10716
|
+
await fs26.writeFile(CACHE_FILE, JSON.stringify(data), "utf-8");
|
|
10883
10717
|
} catch {
|
|
10884
10718
|
}
|
|
10885
10719
|
}
|
|
@@ -10914,10 +10748,10 @@ function buildDeferredUpdateScript(opts) {
|
|
|
10914
10748
|
}
|
|
10915
10749
|
function scheduleDeferredUpdate(command, pid = process.pid, dir = os.tmpdir()) {
|
|
10916
10750
|
const stamp = `${pid}-${process.hrtime.bigint().toString(36)}`;
|
|
10917
|
-
const scriptPath =
|
|
10918
|
-
const logPath =
|
|
10751
|
+
const scriptPath = path45.join(dir, `vg-update-${stamp}.cmd`);
|
|
10752
|
+
const logPath = path45.join(dir, `vg-update-${stamp}.log`);
|
|
10919
10753
|
try {
|
|
10920
|
-
|
|
10754
|
+
fs12.writeFileSync(scriptPath, buildDeferredUpdateScript({ pid, command, logPath }), "utf8");
|
|
10921
10755
|
const child = spawn(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", scriptPath], {
|
|
10922
10756
|
detached: true,
|
|
10923
10757
|
stdio: "ignore",
|
|
@@ -10941,7 +10775,7 @@ function detectGlobalInstall(execPath = process.argv[1] || "", cwd = process.cwd
|
|
|
10941
10775
|
if (!execPath) return null;
|
|
10942
10776
|
let resolved = execPath;
|
|
10943
10777
|
try {
|
|
10944
|
-
resolved =
|
|
10778
|
+
resolved = fs12.realpathSync(execPath);
|
|
10945
10779
|
} catch {
|
|
10946
10780
|
}
|
|
10947
10781
|
const p = resolved.replace(/\\/g, "/");
|
|
@@ -10971,14 +10805,14 @@ async function findGlobalInstall(pkg = PACKAGE_NAME, run = defaultRunner) {
|
|
|
10971
10805
|
pm: "yarn",
|
|
10972
10806
|
root: () => {
|
|
10973
10807
|
const dir = tryRun("yarn global dir");
|
|
10974
|
-
return dir ?
|
|
10808
|
+
return dir ? path45.join(dir, "node_modules") : null;
|
|
10975
10809
|
}
|
|
10976
10810
|
},
|
|
10977
|
-
{ pm: "bun", root: () =>
|
|
10811
|
+
{ pm: "bun", root: () => path45.join(os.homedir(), ".bun", "install", "global", "node_modules") }
|
|
10978
10812
|
];
|
|
10979
10813
|
for (const probe of probes) {
|
|
10980
10814
|
const root3 = probe.root();
|
|
10981
|
-
if (root3 && await pathExists(
|
|
10815
|
+
if (root3 && await pathExists(path45.join(root3, pkg))) return probe.pm;
|
|
10982
10816
|
}
|
|
10983
10817
|
return null;
|
|
10984
10818
|
}
|
|
@@ -10997,15 +10831,15 @@ function getGlobalUpdateCommand(pm, pkg, version) {
|
|
|
10997
10831
|
}
|
|
10998
10832
|
}
|
|
10999
10833
|
async function detectPackageManager(cwd) {
|
|
11000
|
-
if (await pathExists(
|
|
11001
|
-
if (await pathExists(
|
|
11002
|
-
if (await pathExists(
|
|
10834
|
+
if (await pathExists(path45.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
10835
|
+
if (await pathExists(path45.join(cwd, "bun.lockb"))) return "bun";
|
|
10836
|
+
if (await pathExists(path45.join(cwd, "yarn.lock"))) return "yarn";
|
|
11003
10837
|
return "npm";
|
|
11004
10838
|
}
|
|
11005
10839
|
async function detectWorkspaceRoot(cwd) {
|
|
11006
|
-
if (await pathExists(
|
|
10840
|
+
if (await pathExists(path45.join(cwd, "pnpm-workspace.yaml"))) return true;
|
|
11007
10841
|
try {
|
|
11008
|
-
const pkgPath =
|
|
10842
|
+
const pkgPath = path45.join(cwd, "package.json");
|
|
11009
10843
|
const raw = await (await import('fs/promises')).readFile(pkgPath, "utf-8");
|
|
11010
10844
|
const pkg = JSON.parse(raw);
|
|
11011
10845
|
return pkg.workspaces != null;
|
|
@@ -11032,7 +10866,7 @@ function getInstallCommand(pm, pkg, version, isDev, opts = {}) {
|
|
|
11032
10866
|
}
|
|
11033
10867
|
async function getLocalDependencyState(cwd, pkg = PACKAGE_NAME) {
|
|
11034
10868
|
try {
|
|
11035
|
-
const pkgPath =
|
|
10869
|
+
const pkgPath = path45.join(cwd, "package.json");
|
|
11036
10870
|
const raw = await (await import('fs/promises')).readFile(pkgPath, "utf-8");
|
|
11037
10871
|
const parsed = JSON.parse(raw);
|
|
11038
10872
|
if (parsed.devDependencies?.[pkg]) return "dev";
|
|
@@ -11085,7 +10919,7 @@ ${String(err)}` }));
|
|
|
11085
10919
|
async function releaseWindowsFileLocks(cwd, keepVersion) {
|
|
11086
10920
|
reapAndReport(cwd, keepVersion);
|
|
11087
10921
|
try {
|
|
11088
|
-
const { vgdSocketPath } = await import('./vgd-
|
|
10922
|
+
const { vgdSocketPath } = await import('./vgd-XFT574U6.js');
|
|
11089
10923
|
const result = await stopVgd(vgdSocketPath());
|
|
11090
10924
|
if (result === "stopped") {
|
|
11091
10925
|
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 +11050,7 @@ var updateCommand = new Command("update").description("Update vibgrate to the la
|
|
|
11216
11050
|
);
|
|
11217
11051
|
async function rewarmVgdAndReport(cwd) {
|
|
11218
11052
|
try {
|
|
11219
|
-
const { vgdIsRunning, vgdRequest } = await import('./vgd-
|
|
11053
|
+
const { vgdIsRunning, vgdRequest } = await import('./vgd-XFT574U6.js');
|
|
11220
11054
|
if (!await vgdIsRunning()) return;
|
|
11221
11055
|
const loaded = await vgdRequest({ op: "load-graph", root: cwd });
|
|
11222
11056
|
if (!loaded.ok || !("stored" in loaded)) return;
|
|
@@ -11327,13 +11161,13 @@ function collectCandidates(artifact) {
|
|
|
11327
11161
|
return out2;
|
|
11328
11162
|
}
|
|
11329
11163
|
var defaultFixScanner = async (rootDir) => {
|
|
11330
|
-
const scratch =
|
|
11164
|
+
const scratch = path45.join(os.tmpdir(), `vg-fix-scan-${process.pid}.json`);
|
|
11331
11165
|
const scanOpts = { vibgrateVersion: VERSION, format: "json", out: scratch, quiet: true, concurrency: 8 };
|
|
11332
11166
|
const advanced = await loadAdvancedScanHook();
|
|
11333
11167
|
return runCoreScan(rootDir, scanOpts, advanced);
|
|
11334
11168
|
};
|
|
11335
11169
|
async function loadArtifact(rootDir, inFile, scan = defaultFixScanner) {
|
|
11336
|
-
const artifactPath =
|
|
11170
|
+
const artifactPath = path45.isAbsolute(inFile) ? inFile : path45.join(rootDir, inFile);
|
|
11337
11171
|
if (await pathExists(artifactPath)) {
|
|
11338
11172
|
const staleness = scanStaleness(rootDir, artifactPath);
|
|
11339
11173
|
if (!staleness.stale) {
|
|
@@ -11360,7 +11194,7 @@ async function repositoryIdentity(rootDir, override) {
|
|
|
11360
11194
|
}
|
|
11361
11195
|
}
|
|
11362
11196
|
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 =
|
|
11197
|
+
const rootDir = path45.resolve(targetPath);
|
|
11364
11198
|
if (!await pathExists(rootDir)) {
|
|
11365
11199
|
console.error(chalk7.red(`Path does not exist: ${rootDir}`));
|
|
11366
11200
|
process.exit(1);
|
|
@@ -11521,7 +11355,7 @@ function emit(report, format) {
|
|
|
11521
11355
|
}
|
|
11522
11356
|
}
|
|
11523
11357
|
function relProjectDir(rootDir, projectPath) {
|
|
11524
|
-
const rel =
|
|
11358
|
+
const rel = path45.isAbsolute(projectPath) ? path45.relative(rootDir, projectPath) : projectPath;
|
|
11525
11359
|
return rel === "" ? "." : rel;
|
|
11526
11360
|
}
|
|
11527
11361
|
async function buildTargetResolver(rootDir, artifact) {
|
|
@@ -12404,7 +12238,7 @@ function formatMarkdown(artifact) {
|
|
|
12404
12238
|
|
|
12405
12239
|
// src/reporting/commands/report.ts
|
|
12406
12240
|
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 =
|
|
12241
|
+
const artifactPath = path45.resolve(opts.in);
|
|
12408
12242
|
if (!await pathExists(artifactPath)) {
|
|
12409
12243
|
console.error(chalk7.red(`Artifact not found: ${artifactPath}`));
|
|
12410
12244
|
console.error(chalk7.dim('Run "vibgrate scan" first to generate a scan artifact.'));
|
|
@@ -12453,8 +12287,8 @@ function openUrl(url) {
|
|
|
12453
12287
|
// src/reporting/commands/login.ts
|
|
12454
12288
|
var delay = (ms) => new Promise((resolve23) => setTimeout(resolve23, ms));
|
|
12455
12289
|
function isInside(dir, file) {
|
|
12456
|
-
const rel =
|
|
12457
|
-
return !!rel && !rel.startsWith("..") && !
|
|
12290
|
+
const rel = path45.relative(dir, file);
|
|
12291
|
+
return !!rel && !rel.startsWith("..") && !path45.isAbsolute(rel);
|
|
12458
12292
|
}
|
|
12459
12293
|
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
12294
|
"--local",
|
|
@@ -12622,8 +12456,8 @@ var logoutCommand = new Command("logout").description("Clear stored Vibgrate log
|
|
|
12622
12456
|
});
|
|
12623
12457
|
|
|
12624
12458
|
// src/reporting/commands/locale/client.ts
|
|
12625
|
-
function buildUrl(scheme, host,
|
|
12626
|
-
const url = new URL(`${scheme}://${host}/v1/locale${
|
|
12459
|
+
function buildUrl(scheme, host, path47, query) {
|
|
12460
|
+
const url = new URL(`${scheme}://${host}/v1/locale${path47}`);
|
|
12627
12461
|
for (const [key2, value] of Object.entries(query ?? {})) {
|
|
12628
12462
|
if (value !== void 0 && value !== "") url.searchParams.set(key2, String(value));
|
|
12629
12463
|
}
|
|
@@ -12671,8 +12505,8 @@ function createLocaleClient(dsn) {
|
|
|
12671
12505
|
ExitCode.ERROR
|
|
12672
12506
|
);
|
|
12673
12507
|
}
|
|
12674
|
-
const request = async (method,
|
|
12675
|
-
const url = buildUrl(parsed.scheme, parsed.host,
|
|
12508
|
+
const request = async (method, path47, opts = {}) => {
|
|
12509
|
+
const url = buildUrl(parsed.scheme, parsed.host, path47, opts.query);
|
|
12676
12510
|
const body = opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
12677
12511
|
const response = await fetch(url, {
|
|
12678
12512
|
method,
|
|
@@ -12688,17 +12522,17 @@ function createLocaleClient(dsn) {
|
|
|
12688
12522
|
};
|
|
12689
12523
|
return {
|
|
12690
12524
|
workspaceId: parsed.workspaceId,
|
|
12691
|
-
get: (
|
|
12692
|
-
post: (
|
|
12693
|
-
patch: (
|
|
12694
|
-
del: (
|
|
12525
|
+
get: (path47, query) => request("GET", path47, { query }),
|
|
12526
|
+
post: (path47, body) => request("POST", path47, { body }),
|
|
12527
|
+
patch: (path47, body) => request("PATCH", path47, { body }),
|
|
12528
|
+
del: (path47, body) => request("DELETE", path47, { body })
|
|
12695
12529
|
};
|
|
12696
12530
|
}
|
|
12697
12531
|
var LOCALE_CONFIG_FILENAMES = ["vibgrate.locale.yaml", ".vibgrate/locale.yaml"];
|
|
12698
12532
|
function findLocaleConfig(cwd) {
|
|
12699
12533
|
for (const name of LOCALE_CONFIG_FILENAMES) {
|
|
12700
|
-
const candidate =
|
|
12701
|
-
if (
|
|
12534
|
+
const candidate = path45.join(cwd, name);
|
|
12535
|
+
if (fs12.existsSync(candidate)) return candidate;
|
|
12702
12536
|
}
|
|
12703
12537
|
return null;
|
|
12704
12538
|
}
|
|
@@ -12726,10 +12560,10 @@ function loadLocaleConfig(cwd) {
|
|
|
12726
12560
|
const file = findLocaleConfig(cwd);
|
|
12727
12561
|
if (!file) return { config: {}, file: null };
|
|
12728
12562
|
try {
|
|
12729
|
-
return { config: parseLocaleConfig(
|
|
12563
|
+
return { config: parseLocaleConfig(fs12.readFileSync(file, "utf8")), file };
|
|
12730
12564
|
} catch (error) {
|
|
12731
12565
|
throw new Error(
|
|
12732
|
-
`Could not parse ${
|
|
12566
|
+
`Could not parse ${path45.relative(cwd, file)}: ${error instanceof Error ? error.message : String(error)}`
|
|
12733
12567
|
);
|
|
12734
12568
|
}
|
|
12735
12569
|
}
|
|
@@ -12744,9 +12578,9 @@ function serializeLocaleConfig(config) {
|
|
|
12744
12578
|
return stringify(out2);
|
|
12745
12579
|
}
|
|
12746
12580
|
function writeLocaleConfig(cwd, config, filename) {
|
|
12747
|
-
const target = filename ??
|
|
12748
|
-
|
|
12749
|
-
|
|
12581
|
+
const target = filename ?? path45.join(cwd, LOCALE_CONFIG_FILENAMES[0]);
|
|
12582
|
+
fs12.mkdirSync(path45.dirname(target), { recursive: true });
|
|
12583
|
+
fs12.writeFileSync(target, serializeLocaleConfig(config), "utf8");
|
|
12750
12584
|
return target;
|
|
12751
12585
|
}
|
|
12752
12586
|
function resolveLocaleSettings(config, flags) {
|
|
@@ -12887,7 +12721,7 @@ function validatePathTemplate(template) {
|
|
|
12887
12721
|
if (!template.includes("{language}")) {
|
|
12888
12722
|
return 'path template must contain {language} (e.g. "src/locales/{language}/{namespace}.json").';
|
|
12889
12723
|
}
|
|
12890
|
-
if (
|
|
12724
|
+
if (path45.isAbsolute(template)) {
|
|
12891
12725
|
return "path template must be relative to the project directory.";
|
|
12892
12726
|
}
|
|
12893
12727
|
if (template.split(/[\\/]/).includes("..")) {
|
|
@@ -12903,15 +12737,15 @@ function resolveLocaleFiles(cwd, template, languages, namespaces) {
|
|
|
12903
12737
|
for (const language of languages) {
|
|
12904
12738
|
for (const namespace of namespaces) {
|
|
12905
12739
|
const relative13 = renderPath(template, language, namespace);
|
|
12906
|
-
const file =
|
|
12907
|
-
out2.push({ language, namespace, file, relative: relative13, exists:
|
|
12740
|
+
const file = path45.resolve(cwd, relative13);
|
|
12741
|
+
out2.push({ language, namespace, file, relative: relative13, exists: fs12.existsSync(file) });
|
|
12908
12742
|
}
|
|
12909
12743
|
}
|
|
12910
12744
|
return out2;
|
|
12911
12745
|
}
|
|
12912
12746
|
function readCatalog(file, format) {
|
|
12913
|
-
if (!
|
|
12914
|
-
const text =
|
|
12747
|
+
if (!fs12.existsSync(file)) return {};
|
|
12748
|
+
const text = fs12.readFileSync(file, "utf8");
|
|
12915
12749
|
try {
|
|
12916
12750
|
return codecFor(format).decode(text);
|
|
12917
12751
|
} catch (error) {
|
|
@@ -12922,11 +12756,11 @@ function readCatalog(file, format) {
|
|
|
12922
12756
|
}
|
|
12923
12757
|
function writeCatalog(file, format, catalog, opts = {}) {
|
|
12924
12758
|
const encoded = codecFor(format).encode(sortKeys(catalog));
|
|
12925
|
-
const existing =
|
|
12759
|
+
const existing = fs12.existsSync(file) ? fs12.readFileSync(file, "utf8") : null;
|
|
12926
12760
|
const changed = existing !== encoded;
|
|
12927
12761
|
if (changed && !opts.dryRun) {
|
|
12928
|
-
|
|
12929
|
-
|
|
12762
|
+
fs12.mkdirSync(path45.dirname(file), { recursive: true });
|
|
12763
|
+
fs12.writeFileSync(file, encoded, "utf8");
|
|
12930
12764
|
}
|
|
12931
12765
|
return { file, changed, bytes: Buffer.byteLength(encoded, "utf8") };
|
|
12932
12766
|
}
|
|
@@ -12946,7 +12780,7 @@ function diffCatalogs(before, after) {
|
|
|
12946
12780
|
// src/reporting/commands/locale/index.ts
|
|
12947
12781
|
var cwdOption = ["-C, --cwd <dir>", "Run against this directory (default: current)"];
|
|
12948
12782
|
function root(opts) {
|
|
12949
|
-
return
|
|
12783
|
+
return path45.resolve(opts.cwd ?? process.cwd());
|
|
12950
12784
|
}
|
|
12951
12785
|
function withCommonOptions(cmd) {
|
|
12952
12786
|
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 +12850,7 @@ var configCmd = withCommonOptions(
|
|
|
13016
12850
|
if (!isSupportedFormat(next2.format)) codecFor(next2.format);
|
|
13017
12851
|
const written = writeLocaleConfig(dir, next2, file ?? void 0);
|
|
13018
12852
|
emit2(opts, { file: written, config: next2 }, () => {
|
|
13019
|
-
console.log(chalk7.green(`Wrote ${
|
|
12853
|
+
console.log(chalk7.green(`Wrote ${path45.relative(dir, written) || path45.basename(written)}`));
|
|
13020
12854
|
console.log(
|
|
13021
12855
|
chalk7.dim('Credentials are not stored here \u2014 run "vg login" or set VIBGRATE_DSN.')
|
|
13022
12856
|
);
|
|
@@ -13492,7 +13326,7 @@ var vexCommand = new Command("vex").description("Generate an OpenVEX document (e
|
|
|
13492
13326
|
try {
|
|
13493
13327
|
const statements = [];
|
|
13494
13328
|
if (opts.from) {
|
|
13495
|
-
const fromPath =
|
|
13329
|
+
const fromPath = path45.resolve(opts.from);
|
|
13496
13330
|
if (!await pathExists(fromPath)) {
|
|
13497
13331
|
process.stderr.write(chalk7.red(`Statements file not found: ${fromPath}
|
|
13498
13332
|
`));
|
|
@@ -13510,9 +13344,9 @@ var vexCommand = new Command("vex").description("Generate an OpenVEX document (e
|
|
|
13510
13344
|
});
|
|
13511
13345
|
const json2 = JSON.stringify(doc, null, 2);
|
|
13512
13346
|
if (opts.out) {
|
|
13513
|
-
await writeTextFile(
|
|
13347
|
+
await writeTextFile(path45.resolve(opts.out), json2 + "\n");
|
|
13514
13348
|
process.stderr.write(
|
|
13515
|
-
chalk7.green("\u2714") + ` Wrote OpenVEX document (${doc.statements.length} statement(s)) to ${
|
|
13349
|
+
chalk7.green("\u2714") + ` Wrote OpenVEX document (${doc.statements.length} statement(s)) to ${path45.resolve(opts.out)}
|
|
13516
13350
|
`
|
|
13517
13351
|
);
|
|
13518
13352
|
} else {
|
|
@@ -13695,7 +13529,7 @@ function formatDeltaText(base, current) {
|
|
|
13695
13529
|
return lines.join("\n");
|
|
13696
13530
|
}
|
|
13697
13531
|
async function readArtifactOrExit(filePath) {
|
|
13698
|
-
const absolutePath =
|
|
13532
|
+
const absolutePath = path45.resolve(filePath);
|
|
13699
13533
|
if (!await pathExists(absolutePath)) {
|
|
13700
13534
|
console.error(chalk7.red(`Artifact not found: ${absolutePath}`));
|
|
13701
13535
|
process.exit(1);
|
|
@@ -13712,7 +13546,7 @@ var exportCommand = new Command("export").description("Export scan artifact as S
|
|
|
13712
13546
|
const sbom = format === "cyclonedx" ? toCycloneDx(artifact) : toSpdx(artifact);
|
|
13713
13547
|
const body = JSON.stringify(sbom, null, 2);
|
|
13714
13548
|
if (opts.out) {
|
|
13715
|
-
await writeTextFile(
|
|
13549
|
+
await writeTextFile(path45.resolve(opts.out), body);
|
|
13716
13550
|
console.log(chalk7.green("\u2714") + ` SBOM written to ${opts.out}`);
|
|
13717
13551
|
} else {
|
|
13718
13552
|
console.log(body);
|
|
@@ -13723,7 +13557,7 @@ var deltaCommand = new Command("delta").description("Show SBOM delta between two
|
|
|
13723
13557
|
const current = await readArtifactOrExit(opts.to);
|
|
13724
13558
|
const report = formatDeltaText(base, current);
|
|
13725
13559
|
if (opts.out) {
|
|
13726
|
-
await writeTextFile(
|
|
13560
|
+
await writeTextFile(path45.resolve(opts.out), report);
|
|
13727
13561
|
console.log(chalk7.green("\u2714") + ` SBOM delta report written to ${opts.out}`);
|
|
13728
13562
|
} else {
|
|
13729
13563
|
console.log(report);
|
|
@@ -13854,20 +13688,20 @@ function resolveRegime(id) {
|
|
|
13854
13688
|
return regime;
|
|
13855
13689
|
}
|
|
13856
13690
|
function evidenceDir(root3) {
|
|
13857
|
-
return
|
|
13691
|
+
return path45.join(root3, ".vibgrate", "evidence");
|
|
13858
13692
|
}
|
|
13859
13693
|
function orgPath(root3) {
|
|
13860
|
-
return
|
|
13694
|
+
return path45.join(evidenceDir(root3), "org.json");
|
|
13861
13695
|
}
|
|
13862
13696
|
function productsPath(root3) {
|
|
13863
|
-
return
|
|
13697
|
+
return path45.join(evidenceDir(root3), "products.json");
|
|
13864
13698
|
}
|
|
13865
13699
|
function releasesDir(root3) {
|
|
13866
|
-
return
|
|
13700
|
+
return path45.join(evidenceDir(root3), "releases");
|
|
13867
13701
|
}
|
|
13868
13702
|
function releasePath(root3, productId, version) {
|
|
13869
13703
|
const safe = `${productId}@${version}`.replace(/[^A-Za-z0-9._@-]/g, "_");
|
|
13870
|
-
return
|
|
13704
|
+
return path45.join(releasesDir(root3), `${safe}.json`);
|
|
13871
13705
|
}
|
|
13872
13706
|
var DEFAULT_ORG = {
|
|
13873
13707
|
responsiblePersons: [],
|
|
@@ -13898,7 +13732,7 @@ async function freezeRelease(root3, release) {
|
|
|
13898
13732
|
const p = releasePath(root3, release.productId, release.version);
|
|
13899
13733
|
if (await pathExists(p)) {
|
|
13900
13734
|
throw new CliError(
|
|
13901
|
-
`release ${release.productId}@${release.version} is already frozen and manifests are immutable \u2014 delete ${
|
|
13735
|
+
`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
13736
|
ExitCode.USAGE_ERROR
|
|
13903
13737
|
);
|
|
13904
13738
|
}
|
|
@@ -13912,7 +13746,7 @@ async function loadReleases(root3, productId) {
|
|
|
13912
13746
|
const files = (await readdir(dir)).filter((f) => f.endsWith(".json")).sort();
|
|
13913
13747
|
const releases = [];
|
|
13914
13748
|
for (const f of files) {
|
|
13915
|
-
const rel = await readJsonFile(
|
|
13749
|
+
const rel = await readJsonFile(path45.join(dir, f));
|
|
13916
13750
|
if (!productId || rel.productId === productId) releases.push(rel);
|
|
13917
13751
|
}
|
|
13918
13752
|
return releases;
|
|
@@ -14607,19 +14441,19 @@ function verifyEvidenceEnvelope(env, opts = {}) {
|
|
|
14607
14441
|
var DEFAULT_KEY = "attest-key.pem";
|
|
14608
14442
|
function resolveSigningKey(root3, explicit) {
|
|
14609
14443
|
const chosen = process.env.VG_ATTEST_KEY;
|
|
14610
|
-
const keyPath = chosen ?
|
|
14444
|
+
const keyPath = chosen ? path45.resolve(chosen) : path45.join(root3, ".vibgrate", DEFAULT_KEY);
|
|
14611
14445
|
let minted = false;
|
|
14612
|
-
if (!
|
|
14446
|
+
if (!fs12.existsSync(keyPath)) {
|
|
14613
14447
|
if (chosen) throw new CliError(`signing key not found: ${chosen}`, ExitCode.USAGE_ERROR);
|
|
14614
14448
|
const kp = generateKeypair();
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14449
|
+
fs12.mkdirSync(path45.dirname(keyPath), { recursive: true });
|
|
14450
|
+
fs12.writeFileSync(keyPath, kp.privatePem, { mode: 384 });
|
|
14451
|
+
fs12.writeFileSync(`${keyPath}.pub`, kp.publicPem);
|
|
14618
14452
|
minted = true;
|
|
14619
14453
|
}
|
|
14620
14454
|
let key2;
|
|
14621
14455
|
try {
|
|
14622
|
-
key2 = crypto3.createPrivateKey(
|
|
14456
|
+
key2 = crypto3.createPrivateKey(fs12.readFileSync(keyPath, "utf8"));
|
|
14623
14457
|
} catch {
|
|
14624
14458
|
throw new CliError(`could not read an Ed25519 private key from ${keyPath}`, ExitCode.USAGE_ERROR);
|
|
14625
14459
|
}
|
|
@@ -14630,16 +14464,16 @@ function resolveSigningKey(root3, explicit) {
|
|
|
14630
14464
|
}
|
|
14631
14465
|
function writeBundle(input) {
|
|
14632
14466
|
const dir = input.outDir;
|
|
14633
|
-
|
|
14634
|
-
const write = (rel, data) =>
|
|
14467
|
+
fs12.mkdirSync(path45.join(dir, "inputs", "releases"), { recursive: true });
|
|
14468
|
+
const write = (rel, data) => fs12.writeFileSync(path45.join(dir, rel), `${JSON.stringify(data, null, 2)}
|
|
14635
14469
|
`);
|
|
14636
14470
|
write("result.json", input.result);
|
|
14637
|
-
write(
|
|
14471
|
+
write(path45.join("inputs", "advisory.json"), input.advisory);
|
|
14638
14472
|
for (const rel of input.releases) {
|
|
14639
14473
|
const safe = `${rel.productId}@${rel.version}`.replace(/[^A-Za-z0-9._@-]/g, "_");
|
|
14640
|
-
write(
|
|
14474
|
+
write(path45.join("inputs", "releases", `${safe}.json`), rel);
|
|
14641
14475
|
}
|
|
14642
|
-
write(
|
|
14476
|
+
write(path45.join("inputs", "datapack.lock"), { dataPackVersion: input.result.meta.dataPackVersion, kernelVersion: input.result.meta.kernelVersion });
|
|
14643
14477
|
write("provenance.json", {
|
|
14644
14478
|
method: "deterministic",
|
|
14645
14479
|
modelDrafted: [],
|
|
@@ -14655,13 +14489,13 @@ function writeBundle(input) {
|
|
|
14655
14489
|
disclaimer: input.regime.disclaimer
|
|
14656
14490
|
});
|
|
14657
14491
|
if (input.envelope) {
|
|
14658
|
-
|
|
14492
|
+
fs12.writeFileSync(path45.join(dir, "evidence.intoto.jsonl"), `${JSON.stringify(input.envelope)}
|
|
14659
14493
|
`);
|
|
14660
14494
|
}
|
|
14661
14495
|
if (input.timestampToken) {
|
|
14662
|
-
|
|
14496
|
+
fs12.writeFileSync(path45.join(dir, "timestamp.tsr"), input.timestampToken);
|
|
14663
14497
|
}
|
|
14664
|
-
|
|
14498
|
+
fs12.writeFileSync(path45.join(dir, "VERIFY.md"), verifyDoc(input));
|
|
14665
14499
|
return dir;
|
|
14666
14500
|
}
|
|
14667
14501
|
function verifyDoc(input) {
|
|
@@ -14722,13 +14556,13 @@ function undeterminedFields(result, regime) {
|
|
|
14722
14556
|
return gaps.filter((g) => regime.submission.requires.some((r) => g.startsWith(r)) || g.startsWith("exposure") || g.startsWith("member"));
|
|
14723
14557
|
}
|
|
14724
14558
|
async function recordDrill(root3, record) {
|
|
14725
|
-
const dir =
|
|
14726
|
-
const p =
|
|
14559
|
+
const dir = path45.join(evidenceDir(root3), "drills");
|
|
14560
|
+
const p = path45.join(dir, `${record.drillId}.json`);
|
|
14727
14561
|
await writeJsonFile(p, record);
|
|
14728
14562
|
return p;
|
|
14729
14563
|
}
|
|
14730
14564
|
async function hasRecentDrill(root3, asOf) {
|
|
14731
|
-
const dir =
|
|
14565
|
+
const dir = path45.join(evidenceDir(root3), "drills");
|
|
14732
14566
|
if (!await pathExists(dir)) return void 0;
|
|
14733
14567
|
const { readdir } = await import('fs/promises');
|
|
14734
14568
|
const { readJsonFile: readJsonFile2 } = await import('./fs-4G5A65KS.js');
|
|
@@ -14736,7 +14570,7 @@ async function hasRecentDrill(root3, asOf) {
|
|
|
14736
14570
|
if (files.length === 0) return void 0;
|
|
14737
14571
|
const cutoff = new Date(new Date(asOf).getTime() - 90 * 24 * 3600 * 1e3).toISOString();
|
|
14738
14572
|
for (const f of files) {
|
|
14739
|
-
const rec = await readJsonFile2(
|
|
14573
|
+
const rec = await readJsonFile2(path45.join(dir, f));
|
|
14740
14574
|
if (rec.ranAt >= cutoff) return true;
|
|
14741
14575
|
}
|
|
14742
14576
|
return false;
|
|
@@ -14816,7 +14650,7 @@ function formatRegimeList() {
|
|
|
14816
14650
|
|
|
14817
14651
|
// src/reporting/commands/evidence/index.ts
|
|
14818
14652
|
function root2(opts) {
|
|
14819
|
-
return
|
|
14653
|
+
return path45.resolve(opts.cwd ?? process.cwd());
|
|
14820
14654
|
}
|
|
14821
14655
|
function slug(name) {
|
|
14822
14656
|
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "product";
|
|
@@ -14904,7 +14738,7 @@ var releaseCmd = new Command("release").description("Freeze a shipped release in
|
|
|
14904
14738
|
const release = await buildRelease({
|
|
14905
14739
|
productId: product.id,
|
|
14906
14740
|
version,
|
|
14907
|
-
from:
|
|
14741
|
+
from: path45.resolve(rootDir, opts.from),
|
|
14908
14742
|
shipDate: opts.shipDate,
|
|
14909
14743
|
buildId: opts.buildId,
|
|
14910
14744
|
artefactDigest: opts.digest,
|
|
@@ -14912,7 +14746,7 @@ var releaseCmd = new Command("release").description("Freeze a shipped release in
|
|
|
14912
14746
|
frozenAt: nowIso()
|
|
14913
14747
|
});
|
|
14914
14748
|
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 ${
|
|
14749
|
+
console.log(chalk7.green("\u2714") + ` froze ${chalk7.bold(`${product.id}@${version}`)} \u2014 ${release.components.length} components, immutable at ${path45.relative(rootDir, p)}`);
|
|
14916
14750
|
});
|
|
14917
14751
|
async function runExposure(rootDir, vuln, opts) {
|
|
14918
14752
|
const org = await loadOrg(rootDir);
|
|
@@ -14964,7 +14798,7 @@ var exposureCmd = new Command("exposure").description("Which shipped products co
|
|
|
14964
14798
|
console.log("\n" + buildPack(result, regime, org, stage));
|
|
14965
14799
|
}
|
|
14966
14800
|
if (opts.bundle) {
|
|
14967
|
-
const dir =
|
|
14801
|
+
const dir = path45.resolve(rootDir, opts.bundle, `evidence-${result.meta.evidenceId}`);
|
|
14968
14802
|
let envelope;
|
|
14969
14803
|
if (opts.sign !== false) {
|
|
14970
14804
|
const { key: key2, minted } = resolveSigningKey(rootDir);
|
|
@@ -14972,7 +14806,7 @@ var exposureCmd = new Command("exposure").description("Which shipped products co
|
|
|
14972
14806
|
envelope = signEvidenceStatement(buildEvidenceStatement(result, VERSION), key2);
|
|
14973
14807
|
}
|
|
14974
14808
|
writeBundle({ outDir: dir, result, advisory, releases, regime, envelope, timestampToken, cliVersion: VERSION });
|
|
14975
|
-
console.error(chalk7.green("\u2714") + ` evidence bundle written to ${
|
|
14809
|
+
console.error(chalk7.green("\u2714") + ` evidence bundle written to ${path45.relative(rootDir, dir)}${envelope ? " (signed)" : " (unsigned)"}${timestampToken ? " \xB7 RFC 3161" : ""}`);
|
|
14976
14810
|
}
|
|
14977
14811
|
process.exitCode = exposureExit(result.overallStatus);
|
|
14978
14812
|
});
|
|
@@ -15004,7 +14838,7 @@ var packCmd = new Command("pack").description("Build the submission pack a human
|
|
|
15004
14838
|
const stage = opts.stage ?? regime.clocks[0]?.stage ?? "early-warning";
|
|
15005
14839
|
const md = buildPack(result, regime, org, stage);
|
|
15006
14840
|
if (opts.out) {
|
|
15007
|
-
|
|
14841
|
+
fs12.writeFileSync(path45.resolve(rootDir, opts.out), md);
|
|
15008
14842
|
console.error(chalk7.green("\u2714") + ` pack written to ${opts.out}`);
|
|
15009
14843
|
} else {
|
|
15010
14844
|
console.log(md);
|
|
@@ -15046,20 +14880,20 @@ var drillCmd = new Command("drill").description("Timed dry-run of the determinat
|
|
|
15046
14880
|
}
|
|
15047
14881
|
});
|
|
15048
14882
|
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 ?
|
|
14883
|
+
const abs = path45.resolve(bundlePath);
|
|
14884
|
+
const envPath = fs12.statSync(abs).isDirectory() ? path45.join(abs, "evidence.intoto.jsonl") : abs;
|
|
14885
|
+
if (!fs12.existsSync(envPath)) throw new CliError(`no evidence.intoto.jsonl at ${bundlePath}`, ExitCode.NOT_FOUND);
|
|
14886
|
+
const envelope = JSON.parse(fs12.readFileSync(envPath, "utf8").trim().split("\n")[0]);
|
|
14887
|
+
const resultPath = path45.join(path45.dirname(envPath), "result.json");
|
|
14888
|
+
const result = fs12.existsSync(resultPath) ? JSON.parse(fs12.readFileSync(resultPath, "utf8")) : void 0;
|
|
14889
|
+
const publicKeyPem = opts.pub ? fs12.readFileSync(path45.resolve(opts.pub), "utf8") : void 0;
|
|
15056
14890
|
const v = verifyEvidenceEnvelope(envelope, { publicKeyPem, result });
|
|
15057
14891
|
const color = v.status === "verified" ? chalk7.green : v.status === "failed" ? chalk7.red : chalk7.yellow;
|
|
15058
14892
|
console.log(" " + color(v.status.toUpperCase()) + ` ${v.reason}`);
|
|
15059
14893
|
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(
|
|
14894
|
+
const tsrPath = path45.join(path45.dirname(envPath), "timestamp.tsr");
|
|
14895
|
+
if (fs12.existsSync(tsrPath) && result) {
|
|
14896
|
+
const t = verifyTimestamp(fs12.readFileSync(tsrPath), exposureSubjectDigest(result));
|
|
15063
14897
|
const tcolor = t.imprintMatches ? chalk7.green : chalk7.red;
|
|
15064
14898
|
console.log(" " + tcolor("TIMESTAMP") + ` ${t.reason}`);
|
|
15065
14899
|
}
|
|
@@ -15126,12 +14960,12 @@ var exportCmd = new Command("export").description("Air-gap bundle of all evidenc
|
|
|
15126
14960
|
const releases = [];
|
|
15127
14961
|
for (const list of releasesByProduct.values()) releases.push(...list);
|
|
15128
14962
|
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 ${
|
|
14963
|
+
const dir = path45.resolve(rootDir, opts.out);
|
|
14964
|
+
await writeJsonFile(path45.join(dir, "org.json"), org);
|
|
14965
|
+
await writeJsonFile(path45.join(dir, "products.json"), products);
|
|
14966
|
+
for (const r of releases) await writeJsonFile(path45.join(dir, "releases", `${r.productId}@${r.version}.json`.replace(/[^A-Za-z0-9._@-]/g, "_")), r);
|
|
14967
|
+
await writeJsonFile(path45.join(dir, "readiness.json"), report);
|
|
14968
|
+
console.error(chalk7.green("\u2714") + ` exported evidence state to ${path45.relative(rootDir, dir)} (${products.length} products, ${releases.length} frozen releases)`);
|
|
15135
14969
|
});
|
|
15136
14970
|
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
14971
|
const rootDir = root2(opts);
|
|
@@ -15157,10 +14991,10 @@ var pushCmd = new Command("push").description("Push the product registry (and an
|
|
|
15157
14991
|
}));
|
|
15158
14992
|
let exposure;
|
|
15159
14993
|
if (opts.result) {
|
|
15160
|
-
const raw =
|
|
15161
|
-
const resultPath =
|
|
15162
|
-
if (!
|
|
15163
|
-
exposure = JSON.parse(
|
|
14994
|
+
const raw = path45.resolve(rootDir, opts.result);
|
|
14995
|
+
const resultPath = fs12.existsSync(raw) && fs12.statSync(raw).isDirectory() ? path45.join(raw, "result.json") : raw;
|
|
14996
|
+
if (!fs12.existsSync(resultPath)) throw new CliError(`no result.json at ${opts.result}`, ExitCode.NOT_FOUND);
|
|
14997
|
+
exposure = JSON.parse(fs12.readFileSync(resultPath, "utf8"));
|
|
15164
14998
|
}
|
|
15165
14999
|
const payload = { schemaVersion: "evidence-push-1", regime: regime.id, generatedAt: nowIso(), signed: Boolean(opts.signed), products: productPayload, exposure };
|
|
15166
15000
|
const body = JSON.stringify(payload);
|
|
@@ -15359,7 +15193,7 @@ function dispatch(argv, cwd) {
|
|
|
15359
15193
|
}
|
|
15360
15194
|
const looksLikeQuestion = /\s/.test(first) || first.endsWith("?");
|
|
15361
15195
|
if (looksLikeQuestion) return ["ask", ...args];
|
|
15362
|
-
if (
|
|
15196
|
+
if (fs12.existsSync(path45.resolve(cwd, first))) {
|
|
15363
15197
|
return [hasBuildOnlyFlag(args) ? "build" : "scan", ...args];
|
|
15364
15198
|
}
|
|
15365
15199
|
const moved = MOVED_COMMANDS[first];
|
|
@@ -15386,6 +15220,7 @@ function findFirstPositional(args) {
|
|
|
15386
15220
|
async function main(argv = process.argv) {
|
|
15387
15221
|
const raw = argv.slice(2);
|
|
15388
15222
|
if (process.env.NO_COLOR || raw.includes("--no-color")) disableColor();
|
|
15223
|
+
if (!raw.includes("--local")) kickRelevanceReadiness();
|
|
15389
15224
|
const cwd = readCwd(raw);
|
|
15390
15225
|
const program = buildProgram();
|
|
15391
15226
|
program.exitOverride((err) => {
|
|
@@ -15404,9 +15239,9 @@ async function main(argv = process.argv) {
|
|
|
15404
15239
|
}
|
|
15405
15240
|
function readCwd(raw) {
|
|
15406
15241
|
const i = raw.findIndex((a) => a === "-C" || a === "--cwd");
|
|
15407
|
-
if (i >= 0 && raw[i + 1]) return
|
|
15242
|
+
if (i >= 0 && raw[i + 1]) return path45.resolve(raw[i + 1]);
|
|
15408
15243
|
const eq = raw.find((a) => a.startsWith("--cwd="));
|
|
15409
|
-
if (eq) return
|
|
15244
|
+
if (eq) return path45.resolve(eq.slice("--cwd=".length));
|
|
15410
15245
|
return process.cwd();
|
|
15411
15246
|
}
|
|
15412
15247
|
function handleError(err) {
|