@stofone/dsh-agent-roster 0.10.5 → 0.10.6
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/CHANGELOG.md +14 -1
- package/lib/remote.js +22 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.10.6] - 2026-11-03
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **An index cached before an upgrade kept feeding the old shape.** The cache stored an index document
|
|
12
|
+
with no notion of what shape it had, so after upgrading to 0.10.3 — the release that added
|
|
13
|
+
`collection.files` — the panel kept reading a cached index without `files`, fell back to the v1 path, and
|
|
14
|
+
404'd. Caches now carry `CACHE_VERSION`; a mismatch refetches once.
|
|
15
|
+
- A failed fetch on the v1 fallback path now says *why* it is likely failing: if the collection has no
|
|
16
|
+
`files` mapping, the diagnostic points at a stale index (refresh, or delete `.index-cache`) instead of
|
|
17
|
+
leaving a bare `HTTP 404`.
|
|
18
|
+
|
|
7
19
|
## [0.10.5] - 2026-11-03
|
|
8
20
|
|
|
9
21
|
### Fixed
|
|
@@ -512,7 +524,8 @@
|
|
|
512
524
|
- 工具返回值含 `undefined` 键,运行时按 `value is not lossless JSON` 整次拒绝;缺失值统一写 `null`,
|
|
513
525
|
且所有返回值先过 `lib/json.js#lossless`。
|
|
514
526
|
|
|
515
|
-
[Unreleased]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.
|
|
527
|
+
[Unreleased]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.6...main
|
|
528
|
+
[0.10.6]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.5...v0.10.6
|
|
516
529
|
[0.10.5]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.4...v0.10.5
|
|
517
530
|
[0.10.4]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.3...v0.10.4
|
|
518
531
|
[0.10.3]: https://github.com/dsh-agent-roster/dsh-agent-roster/compare/v0.10.2...v0.10.3
|
package/lib/remote.js
CHANGED
|
@@ -49,6 +49,15 @@ export const DEFAULT_REGISTRY_URL =
|
|
|
49
49
|
/** 缓存目录名,放在档案库根下,跟着 `$DSH_HOME` 走。 */
|
|
50
50
|
export const CACHE_DIR_NAME = ".index-cache";
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 索引缓存的语义版本。
|
|
54
|
+
*
|
|
55
|
+
* 缓存里存的是**索引的形状**,而形状会随插件版本变(0.10.3 给 collection 加了 `files`)。
|
|
56
|
+
* 不认版本号的缓存会在升级后继续提供旧形状,表现就是"面板明明装了新版,仍然 404"。
|
|
57
|
+
* 索引语义再变时把这里 +1,老缓存自动失效、重取一次。
|
|
58
|
+
*/
|
|
59
|
+
export const CACHE_VERSION = 2;
|
|
60
|
+
|
|
52
61
|
/** entry 文件所在的仓库前缀(只支持 GitHub raw,不引入 git 协议)。 */
|
|
53
62
|
export const GITHUB_RAW = "https://raw.githubusercontent.com";
|
|
54
63
|
|
|
@@ -266,6 +275,7 @@ export async function loadRegistry(source, options = {}) {
|
|
|
266
275
|
});
|
|
267
276
|
}
|
|
268
277
|
writeCache(cachePath, {
|
|
278
|
+
cacheVersion: CACHE_VERSION,
|
|
269
279
|
sourceId: source.id,
|
|
270
280
|
fetchedAt: current,
|
|
271
281
|
etag: fetched.etag,
|
|
@@ -567,6 +577,17 @@ export async function fetchCollection(collection, options = {}) {
|
|
|
567
577
|
}
|
|
568
578
|
if (loaded === null) {
|
|
569
579
|
diagnostics.push(diagnostic("warn", "collection-fetch-failed", `${collection.id}/${rosterId} 拉取失败:${lastError || "未知原因"}`));
|
|
580
|
+
// 没有 files 映射时退回的是 v1 路径;v2 库在那条路径上必然 404。
|
|
581
|
+
// 这时最可能的原因是"索引是升级前缓存的",提示一句比让用户猜有用。
|
|
582
|
+
if (listedPath === null) {
|
|
583
|
+
diagnostics.push(
|
|
584
|
+
diagnostic(
|
|
585
|
+
"info",
|
|
586
|
+
"index-may-be-stale",
|
|
587
|
+
`${collection.id} 的索引里没有 files 映射,回退到了 v1 路径;若刚升级过插件,先刷新索引(缓存按版本失效,也可删 .index-cache)`,
|
|
588
|
+
),
|
|
589
|
+
);
|
|
590
|
+
}
|
|
570
591
|
continue;
|
|
571
592
|
}
|
|
572
593
|
const parsed = parseDocumentText(loaded.text, { file: loaded.url });
|
|
@@ -669,6 +690,7 @@ export function cachePathFor(cacheDir, id) {
|
|
|
669
690
|
function readCache(file) {
|
|
670
691
|
try {
|
|
671
692
|
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
693
|
+
if (parsed?.cacheVersion !== CACHE_VERSION) return null;
|
|
672
694
|
if (typeof parsed?.fetchedAt !== "number" || typeof parsed?.document !== "object" || parsed.document === null) return null;
|
|
673
695
|
return parsed;
|
|
674
696
|
} catch {
|
package/package.json
CHANGED