docs-cache 0.5.6 → 0.5.7

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.
@@ -188,7 +188,17 @@ const buildLockSource = (result, prior, now) => ({
188
188
  const buildLock = async (plan, previous) => {
189
189
  const toolVersion = await loadToolVersion();
190
190
  const now = (/* @__PURE__ */ new Date()).toISOString();
191
- const sources = { ...previous?.sources ?? {} };
191
+ const configSourceIds = new Set(
192
+ plan.config.sources.map((source) => source.id)
193
+ );
194
+ const sources = {};
195
+ if (previous?.sources) {
196
+ for (const [id, source] of Object.entries(previous.sources)) {
197
+ if (configSourceIds.has(id)) {
198
+ sources[id] = source;
199
+ }
200
+ }
201
+ }
192
202
  for (const result of plan.results) {
193
203
  const prior = sources[result.id];
194
204
  sources[result.id] = buildLockSource(result, prior, now);
@@ -418,8 +418,24 @@ const handleMissingCache = async (params, cachePath, cacheExists) => {
418
418
  await cloneRepo(params, cachePath);
419
419
  return { usedCache: false, worktreeUsed: false };
420
420
  };
421
- const cloneOrUpdateRepo = async (params, outDir) => {
421
+ const cloneOrUpdateInFlight = /* @__PURE__ */ new Map();
422
+ const cloneOrUpdateRepo = (params, outDir) => {
422
423
  const cachePath = getPersistentCachePath(params.repo);
424
+ const inflight = cloneOrUpdateInFlight.get(cachePath);
425
+ if (inflight !== void 0) {
426
+ return inflight.then(() => cloneOrUpdateRepo(params, outDir));
427
+ }
428
+ const promise = (async () => {
429
+ try {
430
+ return await cloneOrUpdateRepoImpl(params, outDir, cachePath);
431
+ } finally {
432
+ cloneOrUpdateInFlight.delete(cachePath);
433
+ }
434
+ })();
435
+ cloneOrUpdateInFlight.set(cachePath, promise);
436
+ return promise;
437
+ };
438
+ const cloneOrUpdateRepoImpl = async (params, outDir, cachePath) => {
423
439
  const cacheExists = await exists(cachePath);
424
440
  const cacheValid = cacheExists && await isValidGitRepo(cachePath);
425
441
  const isCommitRef = /^[0-9a-f]{7,40}$/i.test(params.ref);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "docs-cache",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.5.6",
5
+ "version": "0.5.7",
6
6
  "description": "CLI for deterministic local caching of external documentation for agents and tools",
7
7
  "author": "Frederik Bosch",
8
8
  "license": "MIT",