From b39e23d91a0305822e0cf8b8836af8de76bbf0b7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 30 Oct 2026 14:41:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=B7=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/BootstrapBlazor.LLMsDocs.Cli/README.md | 2 +- .../Services/LlmsDocsClient.cs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/BootstrapBlazor.LLMsDocs.Cli/README.md b/tools/BootstrapBlazor.LLMsDocs.Cli/README.md index 5865e216..6a085b93 100644 --- a/tools/BootstrapBlazor.LLMsDocs.Cli/README.md +++ b/tools/BootstrapBlazor.LLMsDocs.Cli/README.md @@ -127,7 +127,7 @@ bb-llms get Button --base-url ./wwwroot/llms > 含义:官网发版后,最长 24 小时本地才会感知到文档更新(用 `--refresh` 可立即刷新)。 -索引同样缓存。新增组件或扩展服务已发布但提示索引中不存在时,使用 `bb-llms get SelectCity --refresh` 同时刷新索引及目标文档。 +索引同样缓存。`get` 在缓存索引中找不到名称时,会自动回源刷新一次索引后重试,便于发现新增组件或扩展服务;刷新后仍不存在才报错。索引已回源、指定了 `--refresh` / `--no-cache` 或使用本地目录时,不会重复刷新。已有文档内容仍遵循 24 小时缓存,可使用 `bb-llms get SelectCity --refresh` 立即刷新索引及目标文档。此自动刷新行为需要更新到包含该功能的 CLI 版本。 --- diff --git a/tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs b/tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs index 40e6127d..577668d1 100644 --- a/tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs +++ b/tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs @@ -70,8 +70,20 @@ public async Task GetComponentAsync(string name, CancellationToken ct = throw new ArgumentException("Component name is required.", nameof(name)); } - var entry = ParseIndex(await GetIndexAsync(ct)) + var index = ""; + var usedCachedIndex = _useCache && !_refresh && TryReadFreshCache("llms.txt", out index); + if (!usedCachedIndex) + { + index = await GetIndexAsync(ct); + } + + var entry = ParseIndex(index) .FirstOrDefault(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase)); + if (entry is null && usedCachedIndex) + { + entry = ParseIndex(await FetchAsync("llms.txt", ct, refresh: true)) + .FirstOrDefault(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase)); + } if (entry is null) { throw new FileNotFoundException($"Component not found in index: {name}"); @@ -112,7 +124,7 @@ public async Task> SearchAsync(string query, int l // ---- core fetch ------------------------------------------------------- - private async Task FetchAsync(string relativePath, CancellationToken ct) + private async Task FetchAsync(string relativePath, CancellationToken ct, bool refresh = false) { if (!_isRemote) { @@ -127,7 +139,7 @@ private async Task FetchAsync(string relativePath, CancellationToken ct) var url = new Uri(_baseUri!, relativePath); - if (_useCache && !_refresh && TryReadFreshCache(relativePath, out var fresh)) + if (_useCache && !_refresh && !refresh && TryReadFreshCache(relativePath, out var fresh)) { return fresh; } From 48020dbfc88858aee48bced4d3913a5951835db1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 30 Oct 2026 14:51:04 +0800 Subject: [PATCH 2/2] chore: bump version 10.0.6 --- .../BootstrapBlazor.LLMsDocs.Cli.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj b/tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj index 2947a815..09e622c0 100644 --- a/tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj +++ b/tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj @@ -1,7 +1,7 @@ - 10.0.5 + 10.0.6 Exe net10.0 false