claudeup 4.36.0 → 4.38.0

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 (47) hide show
  1. package/package.json +4 -4
  2. package/scripts/verify-community-registry.ts +272 -0
  3. package/src/__tests__/catalog-cache-store.test.ts +271 -0
  4. package/src/__tests__/catalog-notice.test.ts +155 -0
  5. package/src/__tests__/community-fetch.test.ts +545 -0
  6. package/src/__tests__/community-registry.test.ts +269 -0
  7. package/src/__tests__/community-staleness.test.ts +722 -0
  8. package/src/__tests__/github-budget.test.ts +200 -0
  9. package/src/__tests__/open-file.test.ts +59 -0
  10. package/src/__tests__/plugin-manager-fallback.test.ts +200 -8
  11. package/src/__tests__/style-wrap.test.ts +220 -0
  12. package/src/__tests__/styles-manager.test.ts +1124 -0
  13. package/src/__tests__/styles-origins.test.ts +416 -0
  14. package/src/__tests__/styles-screen-state.test.ts +460 -0
  15. package/src/__tests__/styles-status-line.test.ts +72 -0
  16. package/src/__tests__/styles-sync.test.ts +452 -0
  17. package/src/__tests__/tabbar-layout.test.ts +62 -0
  18. package/src/__tests__/terminology-filler.test.ts +214 -0
  19. package/src/data/community-styles.ts +521 -0
  20. package/src/main.tsx +15 -0
  21. package/src/services/catalog-cache-store.ts +312 -0
  22. package/src/services/community-fetcher.ts +90 -0
  23. package/src/services/community-styles.ts +1194 -0
  24. package/src/services/github-budget.ts +274 -0
  25. package/src/services/marketplace-catalog-git.ts +170 -0
  26. package/src/services/marketplace-catalog.ts +95 -0
  27. package/src/services/marketplace-fetcher.ts +310 -87
  28. package/src/services/plugin-manager.ts +103 -92
  29. package/src/services/styles-manager.ts +1400 -0
  30. package/src/services/terminology-filler.ts +266 -0
  31. package/src/ui/App.tsx +15 -3
  32. package/src/ui/adapters/catalogNotice.ts +122 -0
  33. package/src/ui/adapters/stylesAdapter.ts +403 -0
  34. package/src/ui/components/TabBar.tsx +43 -9
  35. package/src/ui/components/layout/ScreenLayout.tsx +19 -2
  36. package/src/ui/components/primitives/ActionHints.tsx +4 -1
  37. package/src/ui/components/primitives/ListCategoryRow.tsx +10 -1
  38. package/src/ui/registry.ts +6 -0
  39. package/src/ui/renderers/pluginRenderers.tsx +39 -1
  40. package/src/ui/renderers/styleRenderers.tsx +809 -0
  41. package/src/ui/screens/PluginsScreen.tsx +138 -29
  42. package/src/ui/screens/StylesScreen.tsx +1089 -0
  43. package/src/ui/screens/index.ts +1 -0
  44. package/src/ui/state/reducer.ts +124 -3
  45. package/src/ui/state/types.ts +76 -3
  46. package/src/utils/config-dir.ts +47 -0
  47. package/src/utils/open-file.ts +84 -0
@@ -1,9 +1,8 @@
1
1
  import path from "node:path";
2
- import os from "node:os";
3
- import { execSync } from "node:child_process";
4
2
  import {
5
3
  getConfiguredMarketplaces,
6
4
  getEnabledPlugins,
5
+ getGlobalClaudeDir,
7
6
  readSettings,
8
7
  writeSettings,
9
8
  getGlobalConfiguredMarketplaces,
@@ -37,13 +36,22 @@ import {
37
36
  } from "../utils/string-utils.js";
38
37
  import {
39
38
  clearMarketplaceCache as clearFetcherCache,
39
+ clearPersistedCatalogs,
40
40
  fetchMarketplacePlugins,
41
+ getMarketplaceFetchFailures,
42
+ isAuthoritative,
41
43
  resolveMarketplacePlugins,
44
+ type CatalogSource,
45
+ type MarketplaceFetchFailure,
42
46
  type MarketplacePlugin,
43
47
  } from "./marketplace-fetcher.js";
44
48
  export {
45
49
  fetchMarketplacePlugins,
50
+ getMarketplaceFetchFailures,
51
+ isAuthoritative,
46
52
  resolveMarketplacePlugins,
53
+ type CatalogSource,
54
+ type MarketplaceFetchFailure,
47
55
  type MarketplacePlugin,
48
56
  };
49
57
  // Cache for local marketplaces (session-level) - Promise-based to prevent race conditions
@@ -110,6 +118,29 @@ export interface PluginInfo {
110
118
  * Never set on the very first run, when there is no baseline to compare to.
111
119
  */
112
120
  recentlyInstalled?: boolean;
121
+ /**
122
+ * Which catalog supplied `version` — i.e. the number this plugin's installed
123
+ * version was compared against.
124
+ *
125
+ * `remote` (HTTP) and `remote-git` (a `git fetch`ed remote ref) are both
126
+ * authoritative — each is upstream's own catalog file. `local-clone` is the
127
+ * checked-out working tree, which is deliberately pinned by
128
+ * `autoUpdate: false`, so its versions can be arbitrarily old.
129
+ */
130
+ catalogSource?: CatalogSource;
131
+ /**
132
+ * Set when `hasUpdate: false` could not actually be verified — the catalog
133
+ * fetch failed and the comparison ran against the pinned clone.
134
+ *
135
+ * This exists because the absence of an update was indistinguishable from a
136
+ * successful check. A rate-limited fetch returned `[]`, the stale clone filled
137
+ * in, its version compared equal to the installed one, and the UI reported
138
+ * "up to date" — the failure rendered as a clean bill of health. Anything that
139
+ * tells the user they are current must check this flag first.
140
+ */
141
+ updateCheckFailed?: boolean;
142
+ /** Why the check failed, for display. Set with `updateCheckFailed`. */
143
+ updateCheckFailure?: MarketplaceFetchFailure;
113
144
  }
114
145
 
115
146
  /**
@@ -241,16 +272,30 @@ export async function getAvailablePlugins(
241
272
  // Fetch local marketplace caches up front so we can detect stale caches
242
273
  let localMarketplaces = await getLocalMarketplaces();
243
274
 
244
- // Fetch plugins from each configured marketplace
245
- for (const mpName of marketplaceNames) {
246
- const marketplace = defaultMarketplaces.find((m) => m.name === mpName);
247
- if (!marketplace) continue;
275
+ // Resolve every marketplace concurrently. These are independent HTTP calls
276
+ // with a 10s timeout each; awaited in sequence, one unreachable marketplace
277
+ // added its full timeout to the "Loading..." the user stares at. Measured on
278
+ // six marketplaces with four unreachable: 44.9s sequential.
279
+ const resolutions = await Promise.all(
280
+ [...marketplaceNames].map(async (mpName) => {
281
+ const marketplace = defaultMarketplaces.find((m) => m.name === mpName);
282
+ if (!marketplace) return null;
283
+ return {
284
+ mpName,
285
+ marketplace,
286
+ resolution: await resolveMarketplacePlugins(
287
+ mpName,
288
+ marketplace.source.repo,
289
+ localMarketplaces,
290
+ ),
291
+ };
292
+ }),
293
+ );
248
294
 
249
- const marketplacePlugins = await resolveMarketplacePlugins(
250
- mpName,
251
- marketplace.source.repo,
252
- localMarketplaces,
253
- );
295
+ for (const entry of resolutions) {
296
+ if (!entry) continue;
297
+ const { mpName, marketplace, resolution } = entry;
298
+ const marketplacePlugins = resolution.plugins;
254
299
 
255
300
  // Auto-sync local cache if remote has plugins the local cache doesn't
256
301
  localMarketplaces = await autoSyncIfStale(
@@ -259,6 +304,13 @@ export async function getAvailablePlugins(
259
304
  localMarketplaces,
260
305
  );
261
306
 
307
+ // The catalog that answered was not the authoritative one, so every
308
+ // version compare below is a guess, not a check.
309
+ // `remote-git` counts as verified: it is upstream's own catalog file, read
310
+ // through a git remote ref rather than over HTTP. Only the pinned working
311
+ // tree (`local-clone`) is untrustworthy for versions.
312
+ const unverified = !isAuthoritative(resolution.source);
313
+
262
314
  for (const plugin of marketplacePlugins) {
263
315
  const pluginId = `${plugin.name}@${mpName}`;
264
316
  const installedVersion = installedVersions[pluginId];
@@ -279,6 +331,9 @@ export async function getAvailablePlugins(
279
331
  installedVersion && plugin.version
280
332
  ? compareVersions(plugin.version, installedVersion) > 0
281
333
  : false,
334
+ catalogSource: resolution.source,
335
+ updateCheckFailed: unverified,
336
+ updateCheckFailure: resolution.failure,
282
337
  ...scopeStatus,
283
338
  category: plugin.category,
284
339
  author: plugin.author,
@@ -438,16 +493,30 @@ export async function getGlobalAvailablePlugins(): Promise<PluginInfo[]> {
438
493
  // Fetch local marketplace caches up front so we can detect stale caches
439
494
  let localMarketplaces = await getLocalMarketplaces();
440
495
 
441
- // Fetch plugins from each configured marketplace
442
- for (const mpName of marketplaceNames) {
443
- const marketplace = defaultMarketplaces.find((m) => m.name === mpName);
444
- if (!marketplace) continue;
496
+ // Resolve every marketplace concurrently. These are independent HTTP calls
497
+ // with a 10s timeout each; awaited in sequence, one unreachable marketplace
498
+ // added its full timeout to the "Loading..." the user stares at. Measured on
499
+ // six marketplaces with four unreachable: 44.9s sequential.
500
+ const resolutions = await Promise.all(
501
+ [...marketplaceNames].map(async (mpName) => {
502
+ const marketplace = defaultMarketplaces.find((m) => m.name === mpName);
503
+ if (!marketplace) return null;
504
+ return {
505
+ mpName,
506
+ marketplace,
507
+ resolution: await resolveMarketplacePlugins(
508
+ mpName,
509
+ marketplace.source.repo,
510
+ localMarketplaces,
511
+ ),
512
+ };
513
+ }),
514
+ );
445
515
 
446
- const marketplacePlugins = await resolveMarketplacePlugins(
447
- mpName,
448
- marketplace.source.repo,
449
- localMarketplaces,
450
- );
516
+ for (const entry of resolutions) {
517
+ if (!entry) continue;
518
+ const { mpName, marketplace, resolution } = entry;
519
+ const marketplacePlugins = resolution.plugins;
451
520
 
452
521
  // Auto-sync local cache if remote has plugins the local cache doesn't
453
522
  localMarketplaces = await autoSyncIfStale(
@@ -456,6 +525,13 @@ export async function getGlobalAvailablePlugins(): Promise<PluginInfo[]> {
456
525
  localMarketplaces,
457
526
  );
458
527
 
528
+ // The catalog that answered was not the authoritative one, so every
529
+ // version compare below is a guess, not a check.
530
+ // `remote-git` counts as verified: it is upstream's own catalog file, read
531
+ // through a git remote ref rather than over HTTP. Only the pinned working
532
+ // tree (`local-clone`) is untrustworthy for versions.
533
+ const unverified = !isAuthoritative(resolution.source);
534
+
459
535
  for (const plugin of marketplacePlugins) {
460
536
  const pluginId = `${plugin.name}@${mpName}`;
461
537
  const installedVersion = installedVersions[pluginId];
@@ -476,6 +552,9 @@ export async function getGlobalAvailablePlugins(): Promise<PluginInfo[]> {
476
552
  installedVersion && plugin.version
477
553
  ? compareVersions(plugin.version, installedVersion) > 0
478
554
  : false,
555
+ catalogSource: resolution.source,
556
+ updateCheckFailed: unverified,
557
+ updateCheckFailure: resolution.failure,
479
558
  ...scopeStatus,
480
559
  category: plugin.category,
481
560
  author: plugin.author,
@@ -798,8 +877,11 @@ export async function refreshAllMarketplaces(
798
877
  ): Promise<RefreshAndRepairResult> {
799
878
  onProgress?.({ current: 1, total: 1, name: "Clearing cache..." });
800
879
 
801
- // Clear all caches to force fresh data
880
+ // Clear all caches to force fresh data. The on-disk catalog cache is awaited
881
+ // rather than fired and forgotten, so the refetch that follows cannot read the
882
+ // entries this is discarding.
802
883
  clearMarketplaceCache();
884
+ await clearPersistedCatalogs();
803
885
 
804
886
  // Auto-repair plugin.json files with missing agents/commands/skills
805
887
  const repairResults = await repairAllMarketplaces();
@@ -810,76 +892,5 @@ export async function refreshAllMarketplaces(
810
892
  };
811
893
  }
812
894
 
813
- export interface MarketplaceUpdateInfo {
814
- name: string;
815
- hasUpdate: boolean;
816
- latestCommit?: string;
817
- currentCommit?: string;
818
- }
819
-
820
- /**
821
- * Check if marketplaces have updates available on GitHub
822
- * Compares local git HEAD with remote HEAD
823
- */
824
- export async function checkMarketplaceUpdates(): Promise<
825
- MarketplaceUpdateInfo[]
826
- > {
827
- const results: MarketplaceUpdateInfo[] = [];
828
- const localMarketplaces = await getLocalMarketplaces();
829
-
830
- for (const [name, marketplace] of localMarketplaces) {
831
- if (!marketplace.gitRepo) continue;
832
-
833
- try {
834
- const marketplacePath = path.join(
835
- os.homedir(),
836
- ".claude",
837
- "plugins",
838
- "marketplaces",
839
- name,
840
- );
841
-
842
- // Get current HEAD from local repo
843
- let currentHead: string;
844
- try {
845
- currentHead = execSync("git rev-parse HEAD", {
846
- cwd: marketplacePath,
847
- encoding: "utf-8",
848
- timeout: 5000,
849
- }).trim();
850
- } catch {
851
- continue; // Skip if can't get HEAD
852
- }
853
-
854
- // Fetch latest commit from GitHub API
855
- const apiUrl = `https://api.github.com/repos/${marketplace.gitRepo}/commits/main`;
856
- const response = await fetch(apiUrl, {
857
- signal: AbortSignal.timeout(10000),
858
- headers: {
859
- Accept: "application/vnd.github.v3+json",
860
- },
861
- });
862
-
863
- if (response.ok) {
864
- const data = (await response.json()) as { sha: string };
865
- const latestCommit = data.sha;
866
-
867
- results.push({
868
- name,
869
- hasUpdate: currentHead !== latestCommit,
870
- currentCommit: currentHead.substring(0, 7),
871
- latestCommit: latestCommit.substring(0, 7),
872
- });
873
- } else {
874
- results.push({ name, hasUpdate: false });
875
- }
876
- } catch {
877
- results.push({ name, hasUpdate: false });
878
- }
879
- }
880
-
881
- return results;
882
- }
883
-
884
895
  // Re-export types for consumers
885
896
  export type { ProgressCallback };