allagents 1.13.8 → 1.13.9

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.
Files changed (2) hide show
  1. package/dist/index.js +149 -99
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18151,12 +18151,33 @@ async function saveRegistryToPath(registry, registryPath) {
18151
18151
  await rm2(temporaryPath, { force: true }).catch(() => {});
18152
18152
  }
18153
18153
  }
18154
+ function mutateRegistry(registryPath, mutate) {
18155
+ const key = resolve6(registryPath);
18156
+ const previousTail = registryMutationTails.get(key) ?? Promise.resolve();
18157
+ const result = previousTail.then(async () => {
18158
+ const registry = await loadRegistryFromPath(key);
18159
+ const mutation = await mutate(registry);
18160
+ if (mutation.changed) {
18161
+ await saveRegistryToPath(registry, key);
18162
+ }
18163
+ return mutation.result;
18164
+ });
18165
+ const tail = result.then(() => {
18166
+ return;
18167
+ }, () => {
18168
+ return;
18169
+ });
18170
+ registryMutationTails.set(key, tail);
18171
+ tail.then(() => {
18172
+ if (registryMutationTails.get(key) === tail) {
18173
+ registryMutationTails.delete(key);
18174
+ }
18175
+ });
18176
+ return result;
18177
+ }
18154
18178
  async function loadRegistry() {
18155
18179
  return loadRegistryFromPath(getRegistryPath());
18156
18180
  }
18157
- async function saveRegistry(registry) {
18158
- return saveRegistryToPath(registry, getRegistryPath());
18159
- }
18160
18181
  function getSourceLocationKey(source) {
18161
18182
  return source.location;
18162
18183
  }
@@ -18260,7 +18281,7 @@ async function addMarketplace(source, customName, branch, _force, scopeOptions)
18260
18281
  }
18261
18282
  }
18262
18283
  const registryPath = scopeOptions?.scope === "project" && scopeOptions?.workspacePath ? getProjectRegistryPath(scopeOptions.workspacePath) : getRegistryPath();
18263
- const registry = await loadRegistryFromPath(registryPath);
18284
+ await loadRegistryFromPath(registryPath);
18264
18285
  const sourceLocation = (() => {
18265
18286
  if (parsed.type === "github") {
18266
18287
  const { owner, repo } = parseLocation(parsed.location);
@@ -18268,8 +18289,6 @@ async function addMarketplace(source, customName, branch, _force, scopeOptions)
18268
18289
  }
18269
18290
  return parsed.location;
18270
18291
  })();
18271
- const existingBySource = findBySourceLocation(registry, sourceLocation);
18272
- let alreadyRegistered = !!existingBySource;
18273
18292
  let marketplacePath;
18274
18293
  let clonedMarketplace = false;
18275
18294
  if (parsed.type === "github" || parsed.type === "git") {
@@ -18336,16 +18355,10 @@ async function addMarketplace(source, customName, branch, _force, scopeOptions)
18336
18355
  };
18337
18356
  }
18338
18357
  if (manifestName !== name) {
18339
- if (getRegistryMarketplace(registry, manifestName)) {
18340
- alreadyRegistered = true;
18341
- }
18342
18358
  name = manifestName;
18343
18359
  }
18344
18360
  }
18345
18361
  }
18346
- if (getRegistryMarketplace(registry, name)) {
18347
- alreadyRegistered = true;
18348
- }
18349
18362
  let entryLocation;
18350
18363
  if (parsed.type === "github") {
18351
18364
  const { owner, repo } = parseLocation(parsed.location);
@@ -18362,13 +18375,18 @@ async function addMarketplace(source, customName, branch, _force, scopeOptions)
18362
18375
  path: marketplacePath,
18363
18376
  lastUpdated: new Date().toISOString()
18364
18377
  };
18365
- setRegistryMarketplace(registry, name, entry);
18366
- await saveRegistryToPath(registry, registryPath);
18367
- return {
18368
- success: true,
18369
- marketplace: entry,
18370
- ...alreadyRegistered && { replaced: true }
18371
- };
18378
+ return mutateRegistry(registryPath, (registry) => {
18379
+ const alreadyRegistered = !!findBySourceLocation(registry, sourceLocation) || !!getRegistryMarketplace(registry, name);
18380
+ setRegistryMarketplace(registry, name, entry);
18381
+ return {
18382
+ changed: true,
18383
+ result: {
18384
+ success: true,
18385
+ marketplace: entry,
18386
+ ...alreadyRegistered && { replaced: true }
18387
+ }
18388
+ };
18389
+ });
18372
18390
  }
18373
18391
  async function removeMarketplace(name, options2 = {}) {
18374
18392
  const scope = options2.scope ?? "all";
@@ -18384,12 +18402,16 @@ async function removeMarketplace(name, options2 = {}) {
18384
18402
  let removedEntry;
18385
18403
  const warnings = [];
18386
18404
  if (scope === "user" || scope === "all") {
18387
- const userRegistry = await loadRegistryFromPath(userRegPath);
18388
- const userEntry = getRegistryMarketplace(userRegistry, name);
18405
+ const userEntry = await mutateRegistry(userRegPath, (registry) => {
18406
+ const entry = getRegistryMarketplace(registry, name);
18407
+ if (!entry) {
18408
+ return { changed: false, result: undefined };
18409
+ }
18410
+ deleteRegistryMarketplace(registry, name);
18411
+ return { changed: true, result: entry };
18412
+ });
18389
18413
  if (userEntry) {
18390
18414
  removedEntry = userEntry;
18391
- deleteRegistryMarketplace(userRegistry, name);
18392
- await saveRegistryToPath(userRegistry, userRegPath);
18393
18415
  if (removedEntry.source.type !== "local" && pathEntryExists(removedEntry.path)) {
18394
18416
  if (hasManagedRemotePath(removedEntry)) {
18395
18417
  await rm2(removedEntry.path, { recursive: true, force: true });
@@ -18401,12 +18423,16 @@ async function removeMarketplace(name, options2 = {}) {
18401
18423
  }
18402
18424
  if ((scope === "project" || scope === "all") && options2.workspacePath) {
18403
18425
  const projectRegPath = getProjectRegistryPath(options2.workspacePath);
18404
- const projectRegistry = await loadRegistryFromPath(projectRegPath);
18405
- const projectEntry = getRegistryMarketplace(projectRegistry, name);
18426
+ const projectEntry = await mutateRegistry(projectRegPath, (registry) => {
18427
+ const entry = getRegistryMarketplace(registry, name);
18428
+ if (!entry) {
18429
+ return { changed: false, result: undefined };
18430
+ }
18431
+ deleteRegistryMarketplace(registry, name);
18432
+ return { changed: true, result: entry };
18433
+ });
18406
18434
  if (projectEntry) {
18407
18435
  removedEntry = projectEntry;
18408
- deleteRegistryMarketplace(projectRegistry, name);
18409
- await saveRegistryToPath(projectRegistry, projectRegPath);
18410
18436
  if (removedEntry.source.type !== "local" && pathEntryExists(removedEntry.path)) {
18411
18437
  if (hasManagedRemotePath(removedEntry)) {
18412
18438
  await rm2(removedEntry.path, { recursive: true, force: true });
@@ -18527,22 +18553,12 @@ async function updateMarketplace(name, workspacePath, deps = {}) {
18527
18553
  if (name && toUpdateScoped.length === 0) {
18528
18554
  return [{ name, success: false, error: `Marketplace '${name}' not found` }];
18529
18555
  }
18530
- const invalidRegistrations = new Set;
18531
- const blockedSaveScopes = new Set;
18532
- let userDirty = false;
18533
- let projectDirty = false;
18556
+ const successfulUpdates = [];
18534
18557
  for (const registration of toUpdateScoped) {
18535
- const { entry: marketplace, key, scope } = registration;
18558
+ const { entry: marketplace } = registration;
18536
18559
  const accessError = getMarketplaceAccessError(marketplace);
18537
18560
  if (accessError) {
18538
- const registry = scope === "user" ? userRegistry : projectRegistry;
18539
18561
  const removal = await removeInvalidMarketplaceRegistration(registration);
18540
- if (removal.removed && registry) {
18541
- deleteRegistryMarketplace(registry, key);
18542
- } else if (!removal.removed) {
18543
- blockedSaveScopes.add(scope);
18544
- }
18545
- invalidRegistrations.add(registration);
18546
18562
  results.push({
18547
18563
  name: marketplace.name,
18548
18564
  success: false,
@@ -18593,11 +18609,13 @@ async function updateMarketplace(name, workspacePath, deps = {}) {
18593
18609
  }
18594
18610
  await git.checkout(targetBranch);
18595
18611
  await (deps.pull ?? pull)(marketplace.path);
18596
- marketplace.lastUpdated = new Date().toISOString();
18612
+ const lastUpdated = deps.now ? deps.now().toISOString() : new Date().toISOString();
18613
+ const resultIndex = results.length;
18597
18614
  results.push({
18598
18615
  name: marketplace.name,
18599
18616
  success: true
18600
18617
  });
18618
+ successfulUpdates.push({ registration, lastUpdated, resultIndex });
18601
18619
  } catch (error) {
18602
18620
  results.push({
18603
18621
  name: marketplace.name,
@@ -18606,23 +18624,37 @@ async function updateMarketplace(name, workspacePath, deps = {}) {
18606
18624
  });
18607
18625
  }
18608
18626
  }
18609
- for (const registration of toUpdateScoped) {
18610
- const { entry, key, scope } = registration;
18611
- if (invalidRegistrations.has(registration))
18612
- continue;
18613
- if (scope === "user") {
18614
- setRegistryMarketplace(userRegistry, key, entry);
18615
- userDirty = true;
18616
- } else if (projectRegistry) {
18617
- setRegistryMarketplace(projectRegistry, key, entry);
18618
- projectDirty = true;
18627
+ const updatesByRegistry = new Map;
18628
+ for (const update of successfulUpdates) {
18629
+ const registryPath = resolve6(update.registration.registryPath);
18630
+ const updates = updatesByRegistry.get(registryPath);
18631
+ if (updates) {
18632
+ updates.push(update);
18633
+ } else {
18634
+ updatesByRegistry.set(registryPath, [update]);
18619
18635
  }
18620
18636
  }
18621
- if (userDirty && !blockedSaveScopes.has("user")) {
18622
- await saveRegistry(userRegistry);
18623
- }
18624
- if (projectDirty && !blockedSaveScopes.has("project") && projectRegistry && projectRegistryPath) {
18625
- await saveRegistryToPath(projectRegistry, projectRegistryPath);
18637
+ for (const [registryPath, updates] of updatesByRegistry) {
18638
+ await mutateRegistry(registryPath, (registry) => {
18639
+ let changed = false;
18640
+ for (const { registration, lastUpdated, resultIndex } of updates) {
18641
+ const currentEntry = getRegistryMarketplace(registry, registration.key);
18642
+ if (!currentEntry || !hasSameMarketplaceIdentity(currentEntry, registration.entry)) {
18643
+ results[resultIndex] = {
18644
+ name: registration.entry.name,
18645
+ success: false,
18646
+ error: `Marketplace '${registration.key}' changed during update. The registry was not overwritten; retry the command.`
18647
+ };
18648
+ continue;
18649
+ }
18650
+ if (currentEntry.lastUpdated !== registration.entry.lastUpdated) {
18651
+ continue;
18652
+ }
18653
+ currentEntry.lastUpdated = lastUpdated;
18654
+ changed = true;
18655
+ }
18656
+ return { changed, result: undefined };
18657
+ });
18626
18658
  }
18627
18659
  return results;
18628
18660
  }
@@ -18790,22 +18822,28 @@ async function resolvePluginSpec(spec, options2 = {}) {
18790
18822
  };
18791
18823
  }
18792
18824
  async function removeInvalidMarketplaceRegistration(registration) {
18793
- const registry = await loadRegistryFromPath(registration.registryPath);
18794
- const currentEntry = getRegistryMarketplace(registry, registration.key);
18795
- if (!currentEntry || !hasSameMarketplaceIdentity(currentEntry, registration.entry)) {
18825
+ return mutateRegistry(registration.registryPath, (registry) => {
18826
+ const currentEntry = getRegistryMarketplace(registry, registration.key);
18827
+ if (!currentEntry || !hasSameMarketplaceIdentity(currentEntry, registration.entry)) {
18828
+ return {
18829
+ changed: false,
18830
+ result: {
18831
+ success: false,
18832
+ removed: false,
18833
+ error: `Marketplace registration '${registration.key}' changed before unsafe cleanup. The registry was not overwritten and no filesystem path was removed; retry the command.`
18834
+ }
18835
+ };
18836
+ }
18837
+ deleteRegistryMarketplace(registry, registration.key);
18796
18838
  return {
18797
- success: false,
18798
- removed: false,
18799
- error: `Marketplace registration '${registration.key}' changed before unsafe cleanup. No registry entry or filesystem path was removed; retry the command.`
18839
+ changed: true,
18840
+ result: {
18841
+ success: false,
18842
+ removed: true,
18843
+ error: getInvalidMarketplaceRegistrationError(registration.key, registration.entry)
18844
+ }
18800
18845
  };
18801
- }
18802
- deleteRegistryMarketplace(registry, registration.key);
18803
- await saveRegistryToPath(registry, registration.registryPath);
18804
- return {
18805
- success: false,
18806
- removed: true,
18807
- error: getInvalidMarketplaceRegistrationError(registration.key, registration.entry)
18808
- };
18846
+ });
18809
18847
  }
18810
18848
  function hasSameMarketplaceIdentity(current, expected) {
18811
18849
  return current.name === expected.name && current.path === expected.path && current.source.type === expected.source.type && current.source.location === expected.source.location;
@@ -18888,42 +18926,53 @@ async function refreshMarketplace(registration) {
18888
18926
  path: managedPath,
18889
18927
  lastUpdated: new Date().toISOString()
18890
18928
  };
18891
- const registry = await loadRegistryFromPath(registration.registryPath);
18892
- const currentEntry = getRegistryMarketplace(registry, registration.key);
18893
- if (!currentEntry || !hasSameMarketplaceIdentity(currentEntry, marketplace)) {
18894
- let cleanupError;
18895
- let restoreError;
18896
- try {
18897
- await rm2(managedPath, { recursive: true, force: true });
18898
- } catch (error) {
18899
- cleanupError = error;
18900
- }
18901
- if (!cleanupError && hadExistingCache && existsSync6(backupPath)) {
18929
+ const result = await mutateRegistry(registration.registryPath, async (registry) => {
18930
+ const currentEntry = getRegistryMarketplace(registry, registration.key);
18931
+ if (!currentEntry || !hasSameMarketplaceIdentity(currentEntry, marketplace)) {
18932
+ let cleanupError;
18933
+ let restoreError;
18902
18934
  try {
18903
- await rename(backupPath, managedPath);
18935
+ await rm2(managedPath, { recursive: true, force: true });
18904
18936
  } catch (error) {
18905
- restoreError = error;
18937
+ cleanupError = error;
18906
18938
  }
18939
+ if (!cleanupError && hadExistingCache && existsSync6(backupPath)) {
18940
+ try {
18941
+ await rename(backupPath, managedPath);
18942
+ } catch (error) {
18943
+ restoreError = error;
18944
+ }
18945
+ }
18946
+ let recoveryMessage = "";
18947
+ if (cleanupError) {
18948
+ const detail = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
18949
+ recoveryMessage = hadExistingCache ? ` Automatic recovery could not remove the replacement cache: ${detail}. The replacement remains at ${managedPath}, and the original cache remains at ${backupPath}.` : ` Automatic cleanup failed: ${detail}. The replacement cache remains at ${managedPath}.`;
18950
+ } else if (restoreError) {
18951
+ const detail = restoreError instanceof Error ? restoreError.message : String(restoreError);
18952
+ recoveryMessage = ` Automatic recovery failed: ${detail}. The original cache remains at ${backupPath}.`;
18953
+ }
18954
+ return {
18955
+ changed: false,
18956
+ result: {
18957
+ success: false,
18958
+ error: `Marketplace registration '${registration.key}' changed during refresh. The registry was not overwritten; retry the command.${recoveryMessage}`
18959
+ }
18960
+ };
18907
18961
  }
18908
- let recoveryMessage = "";
18909
- if (cleanupError) {
18910
- const detail = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
18911
- recoveryMessage = hadExistingCache ? ` Automatic recovery could not remove the replacement cache: ${detail}. The replacement remains at ${managedPath}, and the original cache remains at ${backupPath}.` : ` Automatic cleanup failed: ${detail}. The replacement cache remains at ${managedPath}.`;
18912
- } else if (restoreError) {
18913
- const detail = restoreError instanceof Error ? restoreError.message : String(restoreError);
18914
- recoveryMessage = ` Automatic recovery failed: ${detail}. The original cache remains at ${backupPath}.`;
18915
- }
18962
+ setRegistryMarketplace(registry, registration.key, refreshedMarketplace);
18916
18963
  return {
18917
- success: false,
18918
- error: `Marketplace registration '${registration.key}' changed during refresh. The registry was not overwritten.${recoveryMessage}`
18964
+ changed: true,
18965
+ result: {
18966
+ success: true,
18967
+ marketplace: refreshedMarketplace,
18968
+ replaced: true
18969
+ }
18919
18970
  };
18920
- }
18921
- setRegistryMarketplace(registry, registration.key, refreshedMarketplace);
18922
- await saveRegistryToPath(registry, registration.registryPath);
18923
- if (hadExistingCache) {
18971
+ });
18972
+ if (result.success && hadExistingCache) {
18924
18973
  await rm2(backupPath, { recursive: true, force: true }).catch(() => {});
18925
18974
  }
18926
- return { success: true, marketplace: refreshedMarketplace, replaced: true };
18975
+ return result;
18927
18976
  }
18928
18977
  async function resolvePluginSpecWithAutoRegister(spec, options2 = {}) {
18929
18978
  const parsed = parsePluginSpec(spec);
@@ -19171,7 +19220,7 @@ async function getMarketplaceVersion(marketplace) {
19171
19220
  return null;
19172
19221
  }
19173
19222
  }
19174
- var registeredSourceCache, updatedMarketplaceCache;
19223
+ var registryMutationTails, registeredSourceCache, updatedMarketplaceCache;
19175
19224
  var init_marketplace = __esm(() => {
19176
19225
  init_esm();
19177
19226
  init_constants();
@@ -19180,6 +19229,7 @@ var init_marketplace = __esm(() => {
19180
19229
  init_plugin_path();
19181
19230
  init_git();
19182
19231
  init_plugin();
19232
+ registryMutationTails = new Map;
19183
19233
  registeredSourceCache = new Map;
19184
19234
  updatedMarketplaceCache = new Set;
19185
19235
  });
@@ -46210,7 +46260,7 @@ var package_default;
46210
46260
  var init_package = __esm(() => {
46211
46261
  package_default = {
46212
46262
  name: "allagents",
46213
- version: "1.13.8",
46263
+ version: "1.13.9",
46214
46264
  packageManager: "bun@1.3.12",
46215
46265
  description: "CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",
46216
46266
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allagents",
3
- "version": "1.13.8",
3
+ "version": "1.13.9",
4
4
  "packageManager": "bun@1.3.12",
5
5
  "description": "CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",
6
6
  "type": "module",