@f5-sales-demo/xcsh 21.9.3 → 21.9.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.9.3",
4
+ "version": "21.9.4",
5
5
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -61,13 +61,13 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@agentclientprotocol/sdk": "1.3.0",
64
- "@f5-sales-demo/pi-agent-core": "21.9.3",
65
- "@f5-sales-demo/pi-ai": "21.9.3",
66
- "@f5-sales-demo/pi-natives": "21.9.3",
67
- "@f5-sales-demo/pi-resource-management": "21.9.3",
68
- "@f5-sales-demo/pi-tui": "21.9.3",
69
- "@f5-sales-demo/pi-utils": "21.9.3",
70
- "@f5-sales-demo/xcsh-stats": "21.9.3",
64
+ "@f5-sales-demo/pi-agent-core": "21.9.4",
65
+ "@f5-sales-demo/pi-ai": "21.9.4",
66
+ "@f5-sales-demo/pi-natives": "21.9.4",
67
+ "@f5-sales-demo/pi-resource-management": "21.9.4",
68
+ "@f5-sales-demo/pi-tui": "21.9.4",
69
+ "@f5-sales-demo/pi-utils": "21.9.4",
70
+ "@f5-sales-demo/xcsh-stats": "21.9.4",
71
71
  "@mozilla/readability": "^0.6",
72
72
  "@sinclair/typebox": "^0.34",
73
73
  "@xterm/headless": "^6.0",
@@ -9,6 +9,7 @@ import chalk from "chalk";
9
9
  import { resolveOrDefaultProjectRegistryPath } from "../discovery/helpers";
10
10
  import { PluginManager, parseSettingValue, validateSetting } from "../extensibility/plugins";
11
11
  import {
12
+ formatMarketplaceRefreshWarning,
12
13
  getInstalledPluginsRegistryPath,
13
14
  getMarketplacesCacheDir,
14
15
  getMarketplacesRegistryPath,
@@ -246,8 +247,10 @@ async function handleMarketplace(args: string[], _flags: PluginCommandArgs["flag
246
247
  await manager.updateMarketplace(name);
247
248
  console.log(chalk.green(`${theme.status.success} Updated marketplace: ${name}`));
248
249
  } else {
249
- const results = await manager.updateAllMarketplaces();
250
- console.log(chalk.green(`${theme.status.success} Updated ${results.length} marketplace(s)`));
250
+ const result = await manager.refreshMarketplaces();
251
+ const warning = formatMarketplaceRefreshWarning(result);
252
+ if (warning) console.error(chalk.yellow(warning));
253
+ console.log(chalk.green(`${theme.status.success} Updated ${result.successful.length} marketplace(s)`));
251
254
  }
252
255
  } catch (err) {
253
256
  console.error(chalk.red(`${theme.status.error} Failed to update marketplace: ${err}`));
@@ -285,6 +288,9 @@ async function handleDiscover(args: string[], _flags: PluginCommandArgs["flags"]
285
288
  const marketplace = args[0];
286
289
  const manager = await makeMarketplaceManager();
287
290
  try {
291
+ const refresh = await manager.refreshMarketplaces(marketplace ? [marketplace] : undefined);
292
+ const warning = formatMarketplaceRefreshWarning(refresh);
293
+ if (warning) console.error(chalk.yellow(warning));
288
294
  const plugins = await manager.listAvailablePlugins(marketplace);
289
295
 
290
296
  if (plugins.length === 0) {
@@ -344,12 +350,16 @@ async function handleUpgrade(args: string[], flags: PluginCommandArgs["flags"]):
344
350
  return;
345
351
  }
346
352
 
353
+ const refresh = await manager.refreshMarketplaces();
354
+ const refreshWarning = formatMarketplaceRefreshWarning(refresh);
355
+ if (refreshWarning) console.error(chalk.yellow(refreshWarning));
356
+
347
357
  if (pluginId) {
348
358
  if (flags.scope) {
349
- const result = await manager.upgradePlugin(pluginId, flags.scope, { refresh: true });
359
+ const result = await manager.upgradePlugin(pluginId, flags.scope);
350
360
  console.log(chalk.green(`Upgraded ${pluginId} (${flags.scope}) to ${result.version}`));
351
361
  } else {
352
- const entries = await manager.upgradePluginAcrossScopes(pluginId, { refresh: true });
362
+ const entries = await manager.upgradePluginAcrossScopes(pluginId);
353
363
  for (const entry of entries) {
354
364
  console.log(chalk.green(`Upgraded ${pluginId} (${entry.scope}) to ${entry.version}`));
355
365
  }
@@ -362,7 +372,7 @@ async function handleUpgrade(args: string[], flags: PluginCommandArgs["flags"]):
362
372
  ),
363
373
  );
364
374
  }
365
- const results = await manager.upgradeAllPlugins({ refresh: true });
375
+ const results = await manager.upgradeAllPlugins();
366
376
  if (results.length === 0) {
367
377
  console.log("All marketplace plugins are up to date.");
368
378
  } else {
@@ -395,20 +405,24 @@ async function handleInstall(
395
405
  // marketplace plugin instead of a same-named public npm package.
396
406
  const mktMgr = await makeMarketplaceManager();
397
407
  const marketplaces = await mktMgr.listMarketplaces();
408
+ const preview = flags.dryRun ? await mktMgr.previewMarketplacePlugins() : undefined;
409
+ const refresh = preview ?? (await mktMgr.refreshMarketplaces());
410
+ const refreshWarning = formatMarketplaceRefreshWarning(refresh);
411
+ if (refreshWarning) console.error(chalk.yellow(refreshWarning));
398
412
  const knownMarketplaces = new Set(marketplaces.map(m => m.name));
399
413
  const catalogIndex = new Map<string, string[]>();
400
- for (const mp of marketplaces) {
401
- let plugins: Awaited<ReturnType<typeof mktMgr.listAvailablePlugins>>;
402
- try {
403
- plugins = await mktMgr.listAvailablePlugins(mp.name);
404
- } catch {
405
- continue; // a broken/uncloned catalog must not block installs from others
406
- }
407
- for (const p of plugins) {
408
- const sources = catalogIndex.get(p.name) ?? [];
409
- if (!sources.includes(mp.name)) sources.push(mp.name);
410
- catalogIndex.set(p.name, sources);
411
- }
414
+ const listings = preview
415
+ ? preview.plugins
416
+ : await Promise.all(
417
+ marketplaces.map(async mp => {
418
+ const plugins = await mktMgr.listAvailablePlugins(mp.name).catch(() => []);
419
+ return plugins.map(plugin => ({ marketplace: mp.name, plugin }));
420
+ }),
421
+ ).then(groups => groups.flat());
422
+ for (const { marketplace, plugin } of listings) {
423
+ const sources = catalogIndex.get(plugin.name) ?? [];
424
+ if (!sources.includes(marketplace)) sources.push(marketplace);
425
+ catalogIndex.set(plugin.name, sources);
412
426
  }
413
427
 
414
428
  for (const spec of packages) {
@@ -1,6 +1,7 @@
1
1
  export * from "./cache";
2
2
  export * from "./fetcher";
3
3
  export * from "./manager";
4
+ export * from "./refresh";
4
5
  export * from "./registry";
5
6
  export * from "./source-resolver";
6
7
  export * from "./types";
@@ -69,6 +69,15 @@ export interface PluginUpdate {
69
69
  to: string;
70
70
  }
71
71
 
72
+ export interface MarketplaceRefreshResult {
73
+ successful: string[];
74
+ failed: string[];
75
+ }
76
+
77
+ export interface MarketplaceCatalogPreview extends MarketplaceRefreshResult {
78
+ plugins: Array<{ marketplace: string; plugin: MarketplacePluginEntry }>;
79
+ }
80
+
72
81
  // ── Manager ──────────────────────────────────────────────────────────────────
73
82
 
74
83
  export class MarketplaceManager {
@@ -155,16 +164,10 @@ export class MarketplaceManager {
155
164
  throw new Error(`Marketplace "${name}" not found`);
156
165
  }
157
166
 
158
- let fetchResult: { catalog: MarketplaceCatalog; clonePath?: string };
159
- try {
160
- fetchResult = await fetchMarketplace(existing.sourceUri, this.#opts.marketplacesCacheDir);
161
- } catch (err) {
162
- if (Bun.env.XCSH_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE === "1") {
163
- logger.debug("Marketplace fetch failed, preserving cached catalog", { name, error: String(err) });
164
- return existing;
165
- }
166
- throw err;
167
- }
167
+ const fetchResult: { catalog: MarketplaceCatalog; clonePath?: string } = await fetchMarketplace(
168
+ existing.sourceUri,
169
+ this.#opts.marketplacesCacheDir,
170
+ );
168
171
  const { catalog, clonePath } = fetchResult;
169
172
 
170
173
  // Guard against upstream catalog silently renaming itself — the registry
@@ -217,6 +220,71 @@ export class MarketplaceManager {
217
220
  return reg.marketplaces;
218
221
  }
219
222
 
223
+ /**
224
+ * Best-effort interactive refresh. Unlike refreshStaleMarketplaces(), this always
225
+ * fetches every selected marketplace and isolates failures so cached catalogs remain usable.
226
+ */
227
+ async refreshMarketplaces(names?: readonly string[]): Promise<MarketplaceRefreshResult> {
228
+ const selected = names ?? (await this.listMarketplaces()).map(marketplace => marketplace.name);
229
+ const result: MarketplaceRefreshResult = { successful: [], failed: [] };
230
+
231
+ for (const name of new Set(selected)) {
232
+ try {
233
+ await this.updateMarketplace(name);
234
+ result.successful.push(name);
235
+ } catch (error) {
236
+ logger.debug("Interactive marketplace refresh failed; preserving cached catalog", {
237
+ name,
238
+ error: String(error),
239
+ });
240
+ result.failed.push(name);
241
+ }
242
+ }
243
+
244
+ return result;
245
+ }
246
+
247
+ /** Fetch current catalogs without mutating persistent state (used by dry-run workflows). */
248
+ async previewMarketplacePlugins(names?: readonly string[]): Promise<MarketplaceCatalogPreview> {
249
+ const reg = await readMarketplacesRegistry(this.#opts.marketplacesRegistryPath);
250
+ const selectedNames = names ?? reg.marketplaces.map(marketplace => marketplace.name);
251
+ const selected = new Map(reg.marketplaces.map(marketplace => [marketplace.name, marketplace]));
252
+ const previewDir = await fs.mkdtemp(path.join(os.tmpdir(), "xcsh-marketplace-preview-"));
253
+ const result: MarketplaceCatalogPreview = { successful: [], failed: [], plugins: [] };
254
+
255
+ try {
256
+ for (const name of new Set(selectedNames)) {
257
+ const marketplace = selected.get(name);
258
+ if (!marketplace) {
259
+ result.failed.push(name);
260
+ continue;
261
+ }
262
+
263
+ let catalog: MarketplaceCatalog | undefined;
264
+ try {
265
+ const fetched = await fetchMarketplace(marketplace.sourceUri, previewDir);
266
+ if (fetched.catalog.name !== name) {
267
+ throw new Error(`Marketplace catalog name changed from "${name}" to "${fetched.catalog.name}".`);
268
+ }
269
+ catalog = fetched.catalog;
270
+ result.successful.push(name);
271
+ } catch (error) {
272
+ logger.debug("Marketplace preview refresh failed; using cached catalog when available", {
273
+ name,
274
+ error: String(error),
275
+ });
276
+ result.failed.push(name);
277
+ catalog = await this.#readCatalog(marketplace).catch(() => undefined);
278
+ }
279
+
280
+ for (const plugin of catalog?.plugins ?? []) result.plugins.push({ marketplace: name, plugin });
281
+ }
282
+ return result;
283
+ } finally {
284
+ await fs.rm(previewDir, { recursive: true, force: true });
285
+ }
286
+ }
287
+
220
288
  // ── Plugin discovery ──────────────────────────────────────────────────────
221
289
 
222
290
  async listAvailablePlugins(marketplace?: string): Promise<MarketplacePluginEntry[]> {
@@ -233,8 +301,12 @@ export class MarketplaceManager {
233
301
 
234
302
  const all: MarketplacePluginEntry[] = [];
235
303
  for (const entry of reg.marketplaces) {
236
- const catalog = await this.#readCatalog(entry);
237
- all.push(...catalog.plugins);
304
+ try {
305
+ const catalog = await this.#readCatalog(entry);
306
+ all.push(...catalog.plugins);
307
+ } catch (error) {
308
+ logger.debug("Skipping unavailable marketplace catalog", { name: entry.name, error: String(error) });
309
+ }
238
310
  }
239
311
  return all;
240
312
  }
@@ -574,7 +646,7 @@ export class MarketplaceManager {
574
646
  // Explicit upgrade flows pass refresh:true to re-fetch catalogs from source before
575
647
  // comparing, so freshly-published versions are seen. Passive callers (startup notify,
576
648
  // dashboard poll) omit it and rely on the 24h TTL (refreshStaleMarketplaces).
577
- if (opts?.refresh) await this.updateAllMarketplaces();
649
+ if (opts?.refresh) await this.refreshMarketplaces();
578
650
  const mktReg = await readMarketplacesRegistry(this.#opts.marketplacesRegistryPath);
579
651
  return this.#collectUpdates(mktReg);
580
652
  }
@@ -670,7 +742,7 @@ export class MarketplaceManager {
670
742
  scope?: "user" | "project" | "local",
671
743
  opts?: { refresh?: boolean },
672
744
  ): Promise<InstalledPluginEntry> {
673
- if (opts?.refresh) await this.updateAllMarketplaces();
745
+ if (opts?.refresh) await this.refreshMarketplaces();
674
746
  const parsed = parsePluginId(pluginId);
675
747
  if (!parsed) {
676
748
  throw new Error(`Invalid plugin ID: "${pluginId}". Expected "name@marketplace".`);
@@ -707,7 +779,7 @@ export class MarketplaceManager {
707
779
  // Upgrade a plugin across all scopes where it is installed.
708
780
  // Returns one entry per scope upgraded (0–2 entries).
709
781
  async upgradePluginAcrossScopes(pluginId: string, opts?: { refresh?: boolean }): Promise<InstalledPluginEntry[]> {
710
- if (opts?.refresh) await this.updateAllMarketplaces();
782
+ if (opts?.refresh) await this.refreshMarketplaces();
711
783
  const parsed = parsePluginId(pluginId);
712
784
  if (!parsed) {
713
785
  throw new Error(`Invalid plugin ID: "${pluginId}". Expected "name@marketplace".`);
@@ -0,0 +1,7 @@
1
+ import type { MarketplaceRefreshResult } from "./manager";
2
+
3
+ export function formatMarketplaceRefreshWarning(result: MarketplaceRefreshResult): string | undefined {
4
+ if (result.failed.length === 0) return undefined;
5
+ const noun = result.failed.length === 1 ? "marketplace" : "marketplaces";
6
+ return `Warning: Could not refresh ${noun}: ${result.failed.join(", ")}. Showing last-known catalog data where available (offline/stale).`;
7
+ }
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.9.3",
21
- "commit": "d0f68c91d5de2867aef626f20d80c147bf183f7c",
22
- "shortCommit": "d0f68c9",
20
+ "version": "21.9.4",
21
+ "commit": "37f44eea61d5c229e87076fe92963c7f35913b47",
22
+ "shortCommit": "37f44ee",
23
23
  "branch": "main",
24
- "tag": "v21.9.3",
25
- "commitDate": "2026-09-03T11:54:42+00:00",
26
- "buildDate": "2026-09-03T12:26:26.165Z",
24
+ "tag": "v21.9.4",
25
+ "commitDate": "2026-09-03T15:33:15+00:00",
26
+ "buildDate": "2026-09-03T16:17:03.288Z",
27
27
  "dirty": true,
28
28
  "prNumber": "",
29
29
  "repoUrl": "https://github.com/f5-sales-demo/xcsh",
30
30
  "repoSlug": "f5-sales-demo/xcsh",
31
- "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/d0f68c91d5de2867aef626f20d80c147bf183f7c",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.9.3"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/37f44eea61d5c229e87076fe92963c7f35913b47",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.9.4"
33
33
  };
@@ -16,6 +16,7 @@ import { invalidate as invalidateFsCache } from "../../../capability/fs";
16
16
  import { clearXcshPluginRootsCache, resolveActiveProjectRegistryPath } from "../../../discovery/helpers";
17
17
  import { PluginManager } from "../../../extensibility/plugins";
18
18
  import {
19
+ formatMarketplaceRefreshWarning,
19
20
  getInstalledPluginsRegistryPath,
20
21
  getMarketplacesCacheDir,
21
22
  getMarketplacesRegistryPath,
@@ -27,7 +28,7 @@ import { matchesAppInterrupt } from "../../utils/keybinding-matchers";
27
28
  import { DynamicBorder } from "../dynamic-border";
28
29
  import { PluginInspectorPane } from "./plugin-inspector-pane";
29
30
  import { PluginListPane } from "./plugin-list-pane";
30
- import { applySearch, buildTabs, createInitialState, filterByTab, loadAllPlugins } from "./state-manager";
31
+ import { applySearch, createInitialState, filterByTab, refreshState } from "./state-manager";
31
32
  import type { DashboardPlugin, PluginDashboardState, PluginTabId } from "./types";
32
33
 
33
34
  const DEFAULT_MARKETPLACE = "f5-sales-demo/marketplace";
@@ -113,14 +114,16 @@ export class PluginDashboard extends Container {
113
114
  // Network failure on first run is fine — continue with whatever is available
114
115
  }
115
116
 
117
+ let refreshWarning: string | undefined;
116
118
  try {
117
- await this.#mgr.refreshStaleMarketplaces();
118
- } catch {
119
- // Network failure is fine — display whatever is cached
119
+ refreshWarning = formatMarketplaceRefreshWarning(await this.#mgr.refreshMarketplaces());
120
+ } catch (error) {
121
+ refreshWarning = `Warning: Marketplace refresh failed. Showing last-known catalog data where available (offline/stale): ${error instanceof Error ? error.message : String(error)}`;
120
122
  }
121
123
 
122
124
  try {
123
125
  this.#state = await createInitialState(this.#mgr, this.#npmMgr);
126
+ this.#state.warning = refreshWarning ?? null;
124
127
  } catch (error) {
125
128
  this.#state = {
126
129
  tabs: [{ id: "installed", label: "Installed", count: 0 }],
@@ -132,6 +135,7 @@ export class PluginDashboard extends Container {
132
135
  selectedIndex: 0,
133
136
  scrollOffset: 0,
134
137
  notice: null,
138
+ warning: refreshWarning ?? null,
135
139
  loading: false,
136
140
  loadError: error instanceof Error ? error.message : String(error),
137
141
  };
@@ -197,30 +201,15 @@ export class PluginDashboard extends Container {
197
201
  this.#buildLayout();
198
202
  }
199
203
 
200
- async #reloadData(): Promise<void> {
204
+ async #reloadData(refreshRemote = false): Promise<void> {
201
205
  this.#state.loading = true;
202
206
  this.#state.loadError = null;
203
207
  this.#buildLayout();
204
208
 
205
209
  try {
206
- const selectedId = this.#selectedPlugin()?.id;
207
- const allPlugins = await loadAllPlugins(this.#mgr, this.#npmMgr);
208
- const tabs = buildTabs(allPlugins);
209
- const prevTabId = this.#activeTabId();
210
- const nextTabIndex = Math.max(
211
- 0,
212
- tabs.findIndex(t => t.id === prevTabId),
213
- );
214
-
215
- this.#state.allPlugins = allPlugins;
216
- this.#state.tabs = tabs;
217
- this.#state.activeTabIndex = nextTabIndex;
218
- this.#applyFilters();
219
-
220
- if (selectedId) {
221
- const idx = this.#state.searchFiltered.findIndex(p => p.id === selectedId);
222
- if (idx >= 0) this.#state.selectedIndex = idx;
223
- }
210
+ const refresh = refreshRemote ? await this.#mgr.refreshMarketplaces() : undefined;
211
+ this.#state = await refreshState(this.#state, this.#mgr, this.#npmMgr);
212
+ if (refresh) this.#state.warning = formatMarketplaceRefreshWarning(refresh) ?? null;
224
213
  this.#clampSelection();
225
214
  } catch (error) {
226
215
  this.#state.loadError = error instanceof Error ? error.message : String(error);
@@ -266,6 +255,8 @@ export class PluginDashboard extends Container {
266
255
  this.#rebuildAndRender();
267
256
 
268
257
  try {
258
+ const refresh = await this.#mgr.refreshMarketplaces([plugin.marketplace]);
259
+ this.#state.warning = formatMarketplaceRefreshWarning(refresh) ?? null;
269
260
  await this.#mgr.installPlugin(plugin.name, plugin.marketplace);
270
261
  this.#state.notice = `Installed ${plugin.name}`;
271
262
  await this.#reloadData();
@@ -353,7 +344,9 @@ export class PluginDashboard extends Container {
353
344
  this.#rebuildAndRender();
354
345
 
355
346
  try {
356
- await this.#mgr.upgradePlugin(plugin.id, plugin.scope, { refresh: true });
347
+ const refresh = await this.#mgr.refreshMarketplaces(plugin.marketplace ? [plugin.marketplace] : undefined);
348
+ this.#state.warning = formatMarketplaceRefreshWarning(refresh) ?? null;
349
+ await this.#mgr.upgradePlugin(plugin.id, plugin.scope);
357
350
  this.#state.notice = t("plugins.dashboard.upgraded", { name: plugin.name });
358
351
  await this.#reloadData();
359
352
  } catch (error) {
@@ -409,6 +402,11 @@ export class PluginDashboard extends Container {
409
402
  this.addChild(new Spacer(1));
410
403
  }
411
404
 
405
+ if (this.#state.warning) {
406
+ this.addChild(new Text(theme.fg("warning", replaceTabs(this.#state.warning)), 0, 0));
407
+ this.addChild(new Spacer(1));
408
+ }
409
+
412
410
  if (this.#state.loading) {
413
411
  this.addChild(new Text(theme.fg("muted", "Loading plugins..."), 0, 0));
414
412
  this.addChild(new Spacer(1));
@@ -498,7 +496,7 @@ export class PluginDashboard extends Container {
498
496
  }
499
497
 
500
498
  if (matchesKey(data, "ctrl+r")) {
501
- void this.#reloadData();
499
+ void this.#reloadData(true);
502
500
  return;
503
501
  }
504
502
 
@@ -204,6 +204,7 @@ export async function refreshState(
204
204
  mgr: MarketplaceManager,
205
205
  npmMgr: PluginManager,
206
206
  ): Promise<PluginDashboardState> {
207
+ const selectedId = state.searchFiltered[state.selectedIndex]?.id;
207
208
  const allPlugins = await loadAllPlugins(mgr, npmMgr);
208
209
  const tabs = buildTabs(allPlugins);
209
210
  const prevTabId = state.tabs[state.activeTabIndex]?.id ?? "installed";
@@ -215,7 +216,7 @@ export async function refreshState(
215
216
  const tabFiltered = filterByTab(allPlugins, activeTab?.id ?? "installed");
216
217
  const searchFiltered = applySearch(tabFiltered, state.searchQuery);
217
218
 
218
- return {
219
+ const nextState = {
219
220
  ...state,
220
221
  tabs,
221
222
  activeTabIndex: nextTabIndex,
@@ -226,4 +227,15 @@ export async function refreshState(
226
227
  loading: false,
227
228
  loadError: null,
228
229
  };
230
+ if (selectedId) {
231
+ const selectedIndex = searchFiltered.findIndex(plugin => plugin.id === selectedId);
232
+ if (selectedIndex >= 0) nextState.selectedIndex = selectedIndex;
233
+ }
234
+ if (searchFiltered.length === 0) {
235
+ nextState.selectedIndex = 0;
236
+ nextState.scrollOffset = 0;
237
+ } else {
238
+ nextState.selectedIndex = Math.max(0, Math.min(nextState.selectedIndex, searchFiltered.length - 1));
239
+ }
240
+ return nextState;
229
241
  }
@@ -46,6 +46,7 @@ export interface PluginDashboardState {
46
46
  selectedIndex: number;
47
47
  scrollOffset: number;
48
48
  notice: string | null;
49
+ warning?: string | null;
49
50
  loading: boolean;
50
51
  loadError: string | null;
51
52
  }
@@ -26,6 +26,7 @@ import { DebugSelectorComponent } from "../../debug";
26
26
  import { disableProvider, enableProvider } from "../../discovery";
27
27
  import { clearXcshPluginRootsCache, resolveActiveProjectRegistryPath } from "../../discovery/helpers";
28
28
  import {
29
+ formatMarketplaceRefreshWarning,
29
30
  getInstalledPluginsRegistryPath,
30
31
  getMarketplacesCacheDir,
31
32
  getMarketplacesRegistryPath,
@@ -645,6 +646,9 @@ export class SelectorController {
645
646
  },
646
647
  });
647
648
 
649
+ const refresh = mode === "install" ? await mgr.refreshMarketplaces() : undefined;
650
+ const refreshWarning = refresh ? formatMarketplaceRefreshWarning(refresh) : undefined;
651
+ if (refreshWarning) this.ctx.showStatus(refreshWarning);
648
652
  const [marketplaces, installed] = await Promise.all([mgr.listMarketplaces(), mgr.listInstalledPlugins()]);
649
653
  const installedIds = new Set(installed.map(p => p.id));
650
654
 
@@ -692,7 +696,15 @@ export class SelectorController {
692
696
  marketplace: string;
693
697
  }> = [];
694
698
  for (const mkt of marketplaces) {
695
- const plugins = await mgr.listAvailablePlugins(mkt.name);
699
+ let plugins: Awaited<ReturnType<typeof mgr.listAvailablePlugins>>;
700
+ try {
701
+ plugins = await mgr.listAvailablePlugins(mkt.name);
702
+ } catch (error) {
703
+ this.ctx.showStatus(
704
+ `${refreshWarning ? `${refreshWarning}\n` : ""}Marketplace ${mkt.name} is unavailable: ${error instanceof Error ? error.message : String(error)}`,
705
+ );
706
+ continue;
707
+ }
696
708
  for (const plugin of plugins) {
697
709
  allPlugins.push({ plugin, marketplace: mkt.name });
698
710
  }
@@ -705,9 +717,13 @@ export class SelectorController {
705
717
  this.ctx.showStatus(`Installing ${name} from ${marketplace}...`);
706
718
  this.ctx.ui.requestRender();
707
719
  try {
720
+ const installRefresh = await mgr.refreshMarketplaces([marketplace]);
721
+ const installWarning = formatMarketplaceRefreshWarning(installRefresh);
708
722
  const force = installedIds.has(`${name}@${marketplace}`);
709
723
  await mgr.installPlugin(name, marketplace, { force });
710
- this.ctx.showStatus(`Installed ${name} from ${marketplace}`);
724
+ this.ctx.showStatus(
725
+ `${installWarning ? `${installWarning}\n` : ""}Installed ${name} from ${marketplace}`,
726
+ );
711
727
  } catch (err) {
712
728
  this.ctx.showStatus(`Install failed: ${err}`);
713
729
  }
@@ -13,6 +13,7 @@ import {
13
13
  } from "../discovery/helpers.js";
14
14
  import { PluginManager } from "../extensibility/plugins";
15
15
  import {
16
+ formatMarketplaceRefreshWarning,
16
17
  getInstalledPluginsRegistryPath,
17
18
  getMarketplacesCacheDir,
18
19
  getMarketplacesRegistryPath,
@@ -1008,6 +1009,13 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1008
1009
  });
1009
1010
 
1010
1011
  try {
1012
+ const showPluginStatus = (
1013
+ message: string,
1014
+ refresh?: Awaited<ReturnType<typeof mgr.refreshMarketplaces>>,
1015
+ ) => {
1016
+ const warning = refresh ? formatMarketplaceRefreshWarning(refresh) : undefined;
1017
+ runtime.ctx.showStatus(warning ? `${warning}\n\n${message}` : message);
1018
+ };
1011
1019
  switch (sub) {
1012
1020
  // ── Marketplace management (/plugin marketplace add|remove|update|list) ──
1013
1021
  case "marketplace": {
@@ -1039,9 +1047,10 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1039
1047
  await mgr.updateMarketplace(mktRest);
1040
1048
  runtime.ctx.showStatus(t("commands.plugin.marketplace.updated", { name: mktRest }));
1041
1049
  } else {
1042
- const results = await mgr.updateAllMarketplaces();
1043
- runtime.ctx.showStatus(
1044
- t("commands.plugin.marketplace.updatedAll", { count: results.length }),
1050
+ const refresh = await mgr.refreshMarketplaces();
1051
+ showPluginStatus(
1052
+ t("commands.plugin.marketplace.updatedAll", { count: refresh.successful.length }),
1053
+ refresh,
1045
1054
  );
1046
1055
  }
1047
1056
  break;
@@ -1086,27 +1095,31 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1086
1095
  await mgr.updateMarketplace(rest);
1087
1096
  runtime.ctx.showStatus(t("commands.plugin.marketplace.updated", { name: rest }));
1088
1097
  } else {
1089
- const results = await mgr.updateAllMarketplaces();
1090
- runtime.ctx.showStatus(t("commands.plugin.marketplace.updatedAll", { count: results.length }));
1098
+ const refresh = await mgr.refreshMarketplaces();
1099
+ showPluginStatus(
1100
+ t("commands.plugin.marketplace.updatedAll", { count: refresh.successful.length }),
1101
+ refresh,
1102
+ );
1091
1103
  }
1092
1104
  break;
1093
1105
  }
1094
1106
  // ── Plugin discovery ──
1095
1107
  case "discover": {
1108
+ const refresh = await mgr.refreshMarketplaces(rest ? [rest] : undefined);
1096
1109
  const plugins = await mgr.listAvailablePlugins(rest || undefined);
1097
1110
  if (plugins.length === 0) {
1098
1111
  const marketplaces = await mgr.listMarketplaces();
1099
1112
  if (marketplaces.length === 0) {
1100
- runtime.ctx.showStatus(t("commands.plugin.marketplace.noneConfiguredTry"));
1113
+ showPluginStatus(t("commands.plugin.marketplace.noneConfiguredTry"), refresh);
1101
1114
  } else {
1102
- runtime.ctx.showStatus(t("commands.plugin.marketplace.noPluginsAvailable"));
1115
+ showPluginStatus(t("commands.plugin.marketplace.noPluginsAvailable"), refresh);
1103
1116
  }
1104
1117
  } else {
1105
1118
  const lines = plugins.map(
1106
1119
  p =>
1107
1120
  ` ${p.name}${p.version ? `@${p.version}` : ""}${p.description ? ` - ${p.description}` : ""}`,
1108
1121
  );
1109
- runtime.ctx.showStatus(`Available plugins:\n${lines.join("\n")}`);
1122
+ showPluginStatus(`Available plugins:\n${lines.join("\n")}`, refresh);
1110
1123
  }
1111
1124
  break;
1112
1125
  }
@@ -1120,8 +1133,9 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1120
1133
  const atIdx = parsed.installSpec.lastIndexOf("@");
1121
1134
  const name = parsed.installSpec.slice(0, atIdx);
1122
1135
  const marketplace = parsed.installSpec.slice(atIdx + 1);
1136
+ const refresh = await mgr.refreshMarketplaces([marketplace]);
1123
1137
  await mgr.installPlugin(name, marketplace, { force: parsed.force, scope: parsed.scope });
1124
- runtime.ctx.showStatus(t("commands.plugin.installed", { name, marketplace }));
1138
+ showPluginStatus(t("commands.plugin.installed", { name, marketplace }), refresh);
1125
1139
  break;
1126
1140
  }
1127
1141
  // ── Uninstall ──
@@ -1160,6 +1174,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1160
1174
  }
1161
1175
  // ── Upgrade ──
1162
1176
  case "upgrade": {
1177
+ const refresh = await mgr.refreshMarketplaces();
1163
1178
  if (rest) {
1164
1179
  const upArgs = parsePluginScopeArgs(
1165
1180
  rest,
@@ -1169,18 +1184,20 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1169
1184
  runtime.ctx.showStatus(upArgs.error);
1170
1185
  return;
1171
1186
  }
1172
- const result = await mgr.upgradePlugin(upArgs.pluginId, upArgs.scope, { refresh: true });
1173
- runtime.ctx.showStatus(
1187
+ const result = await mgr.upgradePlugin(upArgs.pluginId, upArgs.scope);
1188
+ showPluginStatus(
1174
1189
  t("commands.plugin.upgraded", { pluginId: upArgs.pluginId, version: result.version }),
1190
+ refresh,
1175
1191
  );
1176
1192
  } else {
1177
- const results = await mgr.upgradeAllPlugins({ refresh: true });
1193
+ const results = await mgr.upgradeAllPlugins();
1178
1194
  if (results.length === 0) {
1179
- runtime.ctx.showStatus(t("commands.plugin.allUpToDate"));
1195
+ showPluginStatus(t("commands.plugin.allUpToDate"), refresh);
1180
1196
  } else {
1181
1197
  const lines = results.map(r => ` ${r.pluginId}: ${r.from} -> ${r.to}`);
1182
- runtime.ctx.showStatus(
1198
+ showPluginStatus(
1183
1199
  `${t("commands.plugin.upgradedCount", { count: results.length })}:\n${lines.join("\n")}`,
1200
+ refresh,
1184
1201
  );
1185
1202
  }
1186
1203
  }
@@ -1247,10 +1264,11 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1247
1264
  }
1248
1265
  // ── Setup (guided recommended plugin install) ──
1249
1266
  case "setup": {
1267
+ const refresh = await mgr.refreshMarketplaces();
1250
1268
  const allPlugins = await mgr.listAvailablePlugins();
1251
1269
  const recommended = allPlugins.filter(p => p.recommended);
1252
1270
  if (recommended.length === 0) {
1253
- runtime.ctx.showStatus(t("commands.plugin.setup.noRecommended"));
1271
+ showPluginStatus(t("commands.plugin.setup.noRecommended"), refresh);
1254
1272
  break;
1255
1273
  }
1256
1274
 
@@ -1261,7 +1279,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1261
1279
  );
1262
1280
 
1263
1281
  if (toSetup.length === 0) {
1264
- runtime.ctx.showStatus(t("commands.plugin.setup.allInstalled"));
1282
+ showPluginStatus(t("commands.plugin.setup.allInstalled"), refresh);
1265
1283
  break;
1266
1284
  }
1267
1285
 
@@ -1346,7 +1364,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<BuiltinSlashCommandSpec> = [
1346
1364
  if (skippedCount > 0) {
1347
1365
  lines.push(t("commands.plugin.setup.skippedCount", { count: skippedCount }));
1348
1366
  }
1349
- runtime.ctx.showStatus(lines.join("\n"));
1367
+ showPluginStatus(lines.join("\n"), refresh);
1350
1368
  break;
1351
1369
  }
1352
1370
  // ── Help ──