Dashboard › cli › Distillation
e8a6737e-f7cf-405b-8217-eaf5f31e6548["lore_tm_v1_eAgpYe9fPP0BqQ09EZYyf81h5TQBLyGHP2xieoZmvEQ","lore_tm_v1_iBLzHozbOlAO8JvttimBss3BsPqqMp8o9kX7b6kfbQo","lore_tm_v1_uEfwCjZKOzn4O_5dt19iV3vYP5_Kgworw8xDhL9mjz4","lore_tm_v1_lRXVKc6RS_QpQchJX1YTmNISQNlhJZibi1OmfZx615s","lore_tm_v1_ID0cXU68SY8NKHsWRa1XNnNChaVEHAG59QpeLUoCfSc","lore_tm_v1_xNg4t8o4wsqBGKiulTLnsXzKBG_5_85zzzKk3jU77TY"]
/home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/node_modules/.pnpm contained 872 entries; the tool displayed entries 1β300. Relevant installed packages included binpatch@0.4.2/, binpunch@1.0.0/, @biomejs+biome@2.3.8/, @types+node@18.19.130/, @types+node@22.20.1/, @types+node@24.13.3/, @vitest+coverage-v8@4.1.10_vitest@4.1.10/, and Vitest packages at 4.1.10.binpatch package directory /home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/node_modules/.pnpm/binpatch@0.4.2/node_modules/binpatch contained exactly 4 entries: dist/, LICENSE, package.json, and README.md./home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/node_modules/.pnpm/binpatch@0.4.2/node_modules/binpatch/dist contained exactly 3 entries: index.d.ts, index.js, and index.js.map.binpatch@0.4.2βs compiled dist/index.js found exactly 45 cache-related matches, including savePatchesToCache, loadAllChainMetas, loadCachedChain, removeExpiredEntries, cleanupPatchCache, clearPatchCache, makeCache, cache-first resolution in resolveAndApply, and the offline_cache_miss error message.binpatch@0.4.2/node_modules/binpatch/dist/index.js, cache constants are CACHE_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3 (7 days) and MAX_CHAIN_WALK_DEPTH = 10; contract constants are MAX_STABLE_CHAIN_DEPTH = 10, MAX_NIGHTLY_CHAIN_DEPTH = 30, SIZE_THRESHOLD_RATIO = 0.6, and PATCH_TAG_PREFIX = "patch-".binpatch cache naming sanitizes versions via version.replace(/[^a-zA-Z0-9.-]/g, "_"); patch files use ${sanitizeVersion(fromVersion)}-${sanitizeVersion(toVersion)}.patch, while metadata files use chain-${sanitizeVersion(fromVersion)}-${sanitizeVersion(toVersion)}.json.savePatchesToCache(cacheDir, chain, steps) creates cacheDir recursively with mode 448, writes each patchβs patch.data, and writes chain metadata containing fromVersion, toVersion, expectedSha256, cachedAt: Date.now(), and per-step fromVersion, toVersion, and size.loadAllChainMetas(cacheDir) returns [] when the directory is absent (ENOENT), reads files matching chain-*.json, ignores malformed metadata by returning null, and filters null results.buildStepMap() keyed by each stepβs fromVersion, then walkChainSteps() follows toVersion links from currentVersion to targetVersion; it returns null for missing links, chains deeper than MAX_CHAIN_WALK_DEPTH, or zero-step chains.loadCachedChain(cacheDir, currentVersion, targetVersion) requires at least one metadata file, a reconstructable chain, and a nonempty expectedSha256 from metadata whose toVersion equals the target; it reads every corresponding patch file, returns null if any patch is absent, and returns { patches, totalSize, expectedSha256 } with totalSize summed from actual data.byteLength.removeExpiredEntries(cacheDir, files, now) deletes malformed metadata, identifies metadata older than CACHE_MAX_AGE_MS, retains patch files still referenced by live metadata, and deletes expired chain metadata plus patch files not shared with live chains. cleanupPatchCache() tolerates a missing cache directory and invokes this expiration logic with Date.now().clearPatchCache(cacheDir) tolerates a missing directory and attempts to unlink every file while swallowing individual unlink failures. makeCache(cacheDir) exposes save, load, cleanup, and clear.BinpatchError supports reasons and default messages: network_error β "Failed to fetch update information.", execution_failed β "Applying the update failed.", version_not_found β "The specified version was not found.", and offline_cache_miss β "Cannot update offline β no pre-downloaded patch is available.".resolveAndApply(opts) checks cache before network resolution; a cache hit emits telemetry?.onResolved?.({ source: "cache", chain: cached }) and applies the chain. If offline after a miss, it emits telemetry?.onOfflineMiss?.() and returns null; otherwise it emits resolve progress, calls source.resolveChain(currentVersion, targetVersion, signal, report), reports unavailability through telemetry?.onUnavailable?.(unavailableReason), asynchronously saves network-resolved chains when cache && chain.steps, emits source "network", and applies the chain.tryLoadCachedChain() suppresses cache-load errors and returns null. safeProgress() suppresses exceptions thrown by progress handlers.applyChain() derives expected apply-byte progress by summing parsePatchHeader(patch.data).newSize, falling back to total = null if parsing fails; it emits phase "apply", applies all in-memory patch buffers through applyPatchChainInMemory, and reports cumulative bytes written.packages/cli/test/lib/patch-cache.test.ts imports cleanupPatchCache and clearPatchCache, uses useTestConfigDir("patch-cache-test-"), and has dedicated test sections for cleanupPatchCache and clearPatchCache.packages/cli/src/lib/patch-cache.ts wraps makeCache(join(getConfigDir(), "patch-cache")) and exports cleanupPatchCache() and clearPatchCache().packages/cli/src/lib/delta-upgrade.ts line 124 returns instrumentCache(makeCache(join(getConfigDir(), "patch-cache"))), and line 543 calls resolveAndApply({ ... }).packages/cli/src/lib/version-check.ts imports cleanupPatchCache at line 30 and awaits it at line 252.packages/cli/src/lib/upgrade.ts imports clearPatchCache at line 66 and calls clearPatchCache().catch(() => { ... }) at line 1107.packages/cli/test/lib/bspatch.test.ts line 523 constructs temporary cache names using bspatch-cache-${Date.now()}-${Math.random().toString(36).slice(2)}-${name}.