dsh-tidy-display 0.3.0 → 0.4.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.
- package/CHANGELOG.de.md +4 -4
- package/CHANGELOG.es.md +4 -4
- package/CHANGELOG.fr.md +4 -4
- package/CHANGELOG.it.md +4 -4
- package/CHANGELOG.md +15 -4
- package/CHANGELOG.ru.md +4 -4
- package/LICENSE +1 -4
- package/README.de.md +5 -5
- package/README.en.md +5 -5
- package/README.es.md +5 -5
- package/README.fr.md +5 -5
- package/README.it.md +5 -5
- package/README.md +5 -5
- package/README.ru.md +5 -5
- package/THIRD_PARTY_NOTICES.md +5 -0
- package/compat/harness-020rc2.json +99 -99
- package/lib/client.js +733 -420
- package/lib/client.js.map +1 -1
- package/lib/types/client/Reader.d.ts.map +1 -1
- package/lib/types/client/Reader.js +10 -6
- package/lib/types/client/Reader.js.map +1 -1
- package/lib/types/client/ReasoningCard.d.ts +2 -1
- package/lib/types/client/ReasoningCard.d.ts.map +1 -1
- package/lib/types/client/ReasoningCard.js +26 -4
- package/lib/types/client/ReasoningCard.js.map +1 -1
- package/lib/types/client/SettingsSection.d.ts +2 -0
- package/lib/types/client/SettingsSection.d.ts.map +1 -1
- package/lib/types/client/SettingsSection.js +2 -1
- package/lib/types/client/SettingsSection.js.map +1 -1
- package/lib/types/client/family-host.d.ts +51 -0
- package/lib/types/client/family-host.d.ts.map +1 -0
- package/lib/types/client/family-host.js +147 -0
- package/lib/types/client/family-host.js.map +1 -0
- package/lib/types/client/settings-copy.d.ts +1 -1
- package/lib/types/client/settings-copy.d.ts.map +1 -1
- package/lib/types/client/settings-copy.js +18 -0
- package/lib/types/client/settings-copy.js.map +1 -1
- package/lib/types/client/settings.d.ts.map +1 -1
- package/lib/types/client/settings.js +18 -8
- package/lib/types/client/settings.js.map +1 -1
- package/lib/types/client/store.d.ts +6 -0
- package/lib/types/client/store.d.ts.map +1 -1
- package/lib/types/client/store.js +2 -0
- package/lib/types/client/store.js.map +1 -1
- package/lib/types/client/types.d.ts +1 -0
- package/lib/types/client/types.d.ts.map +1 -1
- package/package.json +184 -183
- package/scripts/hosts.mjs +80 -80
- package/scripts/sync-hosts.mjs +170 -170
- package/scripts/test-host-compat.mjs +378 -378
- package/src/client/Reader.module.css +47 -3
- package/src/client/Reader.tsx +805 -801
- package/src/client/ReasoningCard.tsx +23 -5
- package/src/client/SettingsSection.tsx +19 -0
- package/src/client/TurnMetrics.module.css +17 -4
- package/src/client/family-host.ts +198 -0
- package/src/client/index.tsx +306 -306
- package/src/client/locales.ts +2422 -2422
- package/src/client/projection.ts +1 -1
- package/src/client/settings-copy.ts +100 -80
- package/src/client/settings.tsx +28 -10
- package/src/client/store.ts +11 -3
- package/src/client/types.ts +1 -0
- package/tests/browser-fold-scroll-issue.tsx +45 -45
package/scripts/sync-hosts.mjs
CHANGED
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sync-hosts.mjs —— 从 hosts.mjs(唯一事实源)下发本仓全部宿主声明写点。
|
|
3
|
-
*
|
|
4
|
-
* 改编自 dsh-date-wrapper/scripts/sync-hosts.mjs(P0 试点定型版),本仓差异:
|
|
5
|
-
* 1. 写点 1 = package.json:engines.dsh + **12 个 dsh-* peer**(全量枚举,optional
|
|
6
|
-
* ——profile 安装 autoInstallPeers:false,peer 不经注册表解析;optional 只影响
|
|
7
|
-
* 独立 npm 安装的开发场景)+ cordis peer(^4.0.2 横跨两代 cordis 线);
|
|
8
|
-
* `react` 为上游生态 peer,不属于宿主声明面,本脚本不碰。
|
|
9
|
-
* 2. 写点 2 = dsh.plugin.json:本仓**没有**插件 manifest(findings §1.2)——存在
|
|
10
|
-
* 才管理(engines.dsh + version 镜像),不存在跳过不报错(INDEX §C 写点全景)。
|
|
11
|
-
* 3. 写点 3 = **七语 README** 管理块(README.md 为简体中文 + en/de/es/fr/it/ru)。
|
|
12
|
-
*
|
|
13
|
-
* 双模式:默认只校验(exit 1 = 有漂移);`--write` 实际写盘。
|
|
14
|
-
* 用法:node scripts/sync-hosts.mjs [--write]
|
|
15
|
-
*/
|
|
16
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
17
|
-
import { existsSync } from 'node:fs'
|
|
18
|
-
import assert from 'node:assert/strict'
|
|
19
|
-
import { supportedHosts, peerRange, developmentHost, hostPeerPackages, cordisRange } from './hosts.mjs'
|
|
20
|
-
|
|
21
|
-
const ROOT = new URL('..', import.meta.url)
|
|
22
|
-
const write = process.argv.includes('--write')
|
|
23
|
-
const read = (rel) => readFile(new URL(rel, ROOT), 'utf8')
|
|
24
|
-
|
|
25
|
-
// ── 0. hosts.mjs 自检 ────────────────────────────────────────────────────────
|
|
26
|
-
const RC_RE = /^\d+\.\d+\.\d+-rc\.\d+$/
|
|
27
|
-
assert(supportedHosts.length > 0, 'supportedHosts 不得为空')
|
|
28
|
-
assert.equal(new Set(supportedHosts).size, supportedHosts.length, 'supportedHosts 有重复项')
|
|
29
|
-
for (const v of supportedHosts) assert(RC_RE.test(v), `非 rc 版本混入枚举: ${v}(本插件只收 rc)`)
|
|
30
|
-
assert(supportedHosts.includes(developmentHost), 'developmentHost 必须在 supportedHosts 内')
|
|
31
|
-
assert(hostPeerPackages.length > 0, 'hostPeerPackages 不得为空')
|
|
32
|
-
|
|
33
|
-
// ── 1. package.json:engines.dsh + 12 个 dsh-* peer + cordis peer ────────────
|
|
34
|
-
const pkgUrl = new URL('package.json', ROOT)
|
|
35
|
-
const pkgOriginal = await read('package.json')
|
|
36
|
-
const pkg = JSON.parse(pkgOriginal)
|
|
37
|
-
pkg.engines ??= {}
|
|
38
|
-
pkg.engines.dsh = peerRange
|
|
39
|
-
pkg.peerDependencies ??= {}
|
|
40
|
-
pkg.peerDependenciesMeta ??= {}
|
|
41
|
-
for (const name of hostPeerPackages) {
|
|
42
|
-
pkg.peerDependencies[name] = peerRange
|
|
43
|
-
// optional:宿主 peer 闸(app-boot evaluatePluginCompatibility)照样逐项比对外来
|
|
44
|
-
// 版本;meta 只影响独立 npm 安装场景——缺失不拦安装(fail-soft 与运行时姿态
|
|
45
|
-
// 一致:webServer/skills/webServer 路由全有守卫)。树内一旦存在但版本不在枚举,
|
|
46
|
-
// npm/pnpm 照样 ERESOLVE。
|
|
47
|
-
pkg.peerDependenciesMeta[name] = { optional: true }
|
|
48
|
-
}
|
|
49
|
-
pkg.peerDependencies['@deepseek-ai/cordis'] = cordisRange
|
|
50
|
-
delete pkg.peerDependenciesMeta['@deepseek-ai/cordis']
|
|
51
|
-
const pkgExpected = JSON.stringify(pkg, null, 2) + '\n'
|
|
52
|
-
|
|
53
|
-
// ── 2. dsh.plugin.json(存在才管理):engines.dsh + manifest version 镜像 ─────
|
|
54
|
-
const pluginJsonUrl = new URL('dsh.plugin.json', ROOT)
|
|
55
|
-
const hasManifest = existsSync(pluginJsonUrl)
|
|
56
|
-
let manifestOriginal, manifestExpected
|
|
57
|
-
if (hasManifest) {
|
|
58
|
-
manifestOriginal = await read('dsh.plugin.json')
|
|
59
|
-
const manifest = JSON.parse(manifestOriginal)
|
|
60
|
-
manifest.engines ??= {}
|
|
61
|
-
manifest.engines.dsh = peerRange
|
|
62
|
-
manifest.version = pkg.version // version 以 package.json 为准,manifest 只镜像
|
|
63
|
-
manifestExpected = JSON.stringify(manifest, null, 2) + '\n'
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ── 3. 七语 README:管理块(支持清单 + 运行时已验证清单) ────────────────────
|
|
67
|
-
const BEGIN = '<!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->'
|
|
68
|
-
const END = '<!-- host-compat:end -->'
|
|
69
|
-
const versionList = supportedHosts.map((v) => `\`${v}\``).join(' ')
|
|
70
|
-
const LINES = '0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0'
|
|
71
|
-
const linesPerLang = {
|
|
72
|
-
'README.md': [
|
|
73
|
-
`- **支持的 DSH 宿主:** ${versionList}(覆盖 ${LINES} 六条线共 ${supportedHosts.length} 个 rc)`,
|
|
74
|
-
],
|
|
75
|
-
'README.en.md': [
|
|
76
|
-
`- **Supported DSH hosts:** ${versionList} (${supportedHosts.length} rc releases across lines ${LINES})`,
|
|
77
|
-
],
|
|
78
|
-
'README.de.md': [
|
|
79
|
-
`- **Unterstützte DSH-Hosts:** ${versionList} (${supportedHosts.length} RC über die Linien ${LINES})`,
|
|
80
|
-
],
|
|
81
|
-
'README.es.md': [
|
|
82
|
-
`- **Hosts DSH compatibles:** ${versionList} (${supportedHosts.length} rc en las líneas ${LINES})`,
|
|
83
|
-
],
|
|
84
|
-
'README.fr.md': [
|
|
85
|
-
`- **Hôtes DSH pris en charge :** ${versionList} (${supportedHosts.length} rc sur les lignes ${LINES})`,
|
|
86
|
-
],
|
|
87
|
-
'README.it.md': [
|
|
88
|
-
`- **Host DSH supportati:** ${versionList} (${supportedHosts.length} rc attraverso le linee ${LINES})`,
|
|
89
|
-
],
|
|
90
|
-
'README.ru.md': [
|
|
91
|
-
`- **Поддерживаемые хосты DSH:** ${versionList} (${supportedHosts.length} rc по линиям ${LINES})`,
|
|
92
|
-
],
|
|
93
|
-
}
|
|
94
|
-
// 矩阵跑绿清单(.compat-results/verified.json,由 scripts/test-host-compat.mjs 写出)
|
|
95
|
-
const verifiedUrl = new URL('.compat-results/verified.json', ROOT)
|
|
96
|
-
if (existsSync(verifiedUrl)) {
|
|
97
|
-
const { verified = [] } = JSON.parse(await readFile(verifiedUrl, 'utf8'))
|
|
98
|
-
if (verified.length > 0) {
|
|
99
|
-
const list = verified.map((v) => `\`${v}\``).join(', ')
|
|
100
|
-
const verifiedLine = {
|
|
101
|
-
'README.md': `- **运行时已验证:** ${list}(证据见 \`.compat-results/\`)`,
|
|
102
|
-
'README.en.md': `- **Runtime-verified:** ${list} — evidence in \`.compat-results/\``,
|
|
103
|
-
'README.de.md': `- **Zur Laufzeit verifiziert:** ${list} — Nachweise in \`.compat-results/\``,
|
|
104
|
-
'README.es.md': `- **Verificado en tiempo de ejecución:** ${list} — evidencia en \`.compat-results/\``,
|
|
105
|
-
'README.fr.md': `- **Vérifié à l'exécution :** ${list} — preuves dans \`.compat-results/\``,
|
|
106
|
-
'README.it.md': `- **Verificato a runtime:** ${list} — prove in \`.compat-results/\``,
|
|
107
|
-
'README.ru.md': `- **Проверено на этапе выполнения:** ${list} — доказательства в \`.compat-results/\``,
|
|
108
|
-
}
|
|
109
|
-
for (const [file, line] of Object.entries(verifiedLine)) linesPerLang[file].push(line)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const readmeProblems = []
|
|
113
|
-
for (const [file, lines] of Object.entries(linesPerLang)) {
|
|
114
|
-
const block = `${BEGIN}\n${lines.join('\n')}\n${END}`
|
|
115
|
-
const url = new URL(file, ROOT)
|
|
116
|
-
const content = await readFile(url, 'utf8')
|
|
117
|
-
const beginAt = content.indexOf(BEGIN)
|
|
118
|
-
if (beginAt === -1) {
|
|
119
|
-
// 插入点:第一个 `## ` 二级标题前(七语结构一致)
|
|
120
|
-
const at = content.search(/^## /m)
|
|
121
|
-
assert(at !== -1, `${file} 找不到插入锚点(第一个二级标题)`)
|
|
122
|
-
if (write) {
|
|
123
|
-
await writeFile(url, content.slice(0, at) + block + '\n\n' + content.slice(at))
|
|
124
|
-
console.log(`write ${file}: 插入管理块`)
|
|
125
|
-
} else {
|
|
126
|
-
readmeProblems.push(`${file} 缺少 host-compat 管理块`)
|
|
127
|
-
}
|
|
128
|
-
continue
|
|
129
|
-
}
|
|
130
|
-
const endAt = content.indexOf(END, beginAt)
|
|
131
|
-
assert(endAt !== -1, `${file} 管理块缺少 end 标记`)
|
|
132
|
-
const current = content.slice(beginAt, endAt + END.length)
|
|
133
|
-
if (write) {
|
|
134
|
-
if (current !== block) {
|
|
135
|
-
await writeFile(url, content.slice(0, beginAt) + block + content.slice(endAt + END.length))
|
|
136
|
-
console.log(`write ${file}: 更新管理块`)
|
|
137
|
-
} else {
|
|
138
|
-
console.log(`ok ${file}: 管理块已是最新`)
|
|
139
|
-
}
|
|
140
|
-
} else if (current !== block) {
|
|
141
|
-
readmeProblems.push(`${file} 管理块内容需要同步`)
|
|
142
|
-
} else {
|
|
143
|
-
console.log(`ok ${file}: 管理块已是最新`)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ── 4. 汇总校验/写盘 ────────────────────────────────────────────────────────
|
|
148
|
-
if (write) {
|
|
149
|
-
if (pkgOriginal !== pkgExpected) {
|
|
150
|
-
await writeFile(pkgUrl, pkgExpected)
|
|
151
|
-
console.log('write package.json (engines.dsh + 12 dsh-* peers + cordis)')
|
|
152
|
-
} else console.log('ok package.json')
|
|
153
|
-
if (hasManifest) {
|
|
154
|
-
if (manifestOriginal !== manifestExpected) {
|
|
155
|
-
await writeFile(pluginJsonUrl, manifestExpected)
|
|
156
|
-
console.log('write dsh.plugin.json (engines.dsh + version)')
|
|
157
|
-
} else console.log('ok dsh.plugin.json')
|
|
158
|
-
} else console.log('skip dsh.plugin.json(本仓无插件 manifest)')
|
|
159
|
-
console.log('done --write 完成')
|
|
160
|
-
} else {
|
|
161
|
-
const jsonDrift = pkgOriginal !== pkgExpected ? ['package.json (engines.dsh / peerDependencies / cordis)'] : []
|
|
162
|
-
if (hasManifest && manifestOriginal !== manifestExpected) jsonDrift.push('dsh.plugin.json (engines.dsh / version)')
|
|
163
|
-
if (jsonDrift.length === 0 && readmeProblems.length === 0) {
|
|
164
|
-
console.log('ok 全部写点与 hosts.mjs 一致')
|
|
165
|
-
} else {
|
|
166
|
-
for (const p of [...jsonDrift, ...readmeProblems]) console.error(`drift ${p}`)
|
|
167
|
-
console.error('\n运行 node scripts/sync-hosts.mjs --write 修复')
|
|
168
|
-
process.exit(1)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* sync-hosts.mjs —— 从 hosts.mjs(唯一事实源)下发本仓全部宿主声明写点。
|
|
3
|
+
*
|
|
4
|
+
* 改编自 dsh-date-wrapper/scripts/sync-hosts.mjs(P0 试点定型版),本仓差异:
|
|
5
|
+
* 1. 写点 1 = package.json:engines.dsh + **12 个 dsh-* peer**(全量枚举,optional
|
|
6
|
+
* ——profile 安装 autoInstallPeers:false,peer 不经注册表解析;optional 只影响
|
|
7
|
+
* 独立 npm 安装的开发场景)+ cordis peer(^4.0.2 横跨两代 cordis 线);
|
|
8
|
+
* `react` 为上游生态 peer,不属于宿主声明面,本脚本不碰。
|
|
9
|
+
* 2. 写点 2 = dsh.plugin.json:本仓**没有**插件 manifest(findings §1.2)——存在
|
|
10
|
+
* 才管理(engines.dsh + version 镜像),不存在跳过不报错(INDEX §C 写点全景)。
|
|
11
|
+
* 3. 写点 3 = **七语 README** 管理块(README.md 为简体中文 + en/de/es/fr/it/ru)。
|
|
12
|
+
*
|
|
13
|
+
* 双模式:默认只校验(exit 1 = 有漂移);`--write` 实际写盘。
|
|
14
|
+
* 用法:node scripts/sync-hosts.mjs [--write]
|
|
15
|
+
*/
|
|
16
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
17
|
+
import { existsSync } from 'node:fs'
|
|
18
|
+
import assert from 'node:assert/strict'
|
|
19
|
+
import { supportedHosts, peerRange, developmentHost, hostPeerPackages, cordisRange } from './hosts.mjs'
|
|
20
|
+
|
|
21
|
+
const ROOT = new URL('..', import.meta.url)
|
|
22
|
+
const write = process.argv.includes('--write')
|
|
23
|
+
const read = (rel) => readFile(new URL(rel, ROOT), 'utf8')
|
|
24
|
+
|
|
25
|
+
// ── 0. hosts.mjs 自检 ────────────────────────────────────────────────────────
|
|
26
|
+
const RC_RE = /^\d+\.\d+\.\d+-rc\.\d+$/
|
|
27
|
+
assert(supportedHosts.length > 0, 'supportedHosts 不得为空')
|
|
28
|
+
assert.equal(new Set(supportedHosts).size, supportedHosts.length, 'supportedHosts 有重复项')
|
|
29
|
+
for (const v of supportedHosts) assert(RC_RE.test(v), `非 rc 版本混入枚举: ${v}(本插件只收 rc)`)
|
|
30
|
+
assert(supportedHosts.includes(developmentHost), 'developmentHost 必须在 supportedHosts 内')
|
|
31
|
+
assert(hostPeerPackages.length > 0, 'hostPeerPackages 不得为空')
|
|
32
|
+
|
|
33
|
+
// ── 1. package.json:engines.dsh + 12 个 dsh-* peer + cordis peer ────────────
|
|
34
|
+
const pkgUrl = new URL('package.json', ROOT)
|
|
35
|
+
const pkgOriginal = await read('package.json')
|
|
36
|
+
const pkg = JSON.parse(pkgOriginal)
|
|
37
|
+
pkg.engines ??= {}
|
|
38
|
+
pkg.engines.dsh = peerRange
|
|
39
|
+
pkg.peerDependencies ??= {}
|
|
40
|
+
pkg.peerDependenciesMeta ??= {}
|
|
41
|
+
for (const name of hostPeerPackages) {
|
|
42
|
+
pkg.peerDependencies[name] = peerRange
|
|
43
|
+
// optional:宿主 peer 闸(app-boot evaluatePluginCompatibility)照样逐项比对外来
|
|
44
|
+
// 版本;meta 只影响独立 npm 安装场景——缺失不拦安装(fail-soft 与运行时姿态
|
|
45
|
+
// 一致:webServer/skills/webServer 路由全有守卫)。树内一旦存在但版本不在枚举,
|
|
46
|
+
// npm/pnpm 照样 ERESOLVE。
|
|
47
|
+
pkg.peerDependenciesMeta[name] = { optional: true }
|
|
48
|
+
}
|
|
49
|
+
pkg.peerDependencies['@deepseek-ai/cordis'] = cordisRange
|
|
50
|
+
delete pkg.peerDependenciesMeta['@deepseek-ai/cordis']
|
|
51
|
+
const pkgExpected = JSON.stringify(pkg, null, 2) + '\n'
|
|
52
|
+
|
|
53
|
+
// ── 2. dsh.plugin.json(存在才管理):engines.dsh + manifest version 镜像 ─────
|
|
54
|
+
const pluginJsonUrl = new URL('dsh.plugin.json', ROOT)
|
|
55
|
+
const hasManifest = existsSync(pluginJsonUrl)
|
|
56
|
+
let manifestOriginal, manifestExpected
|
|
57
|
+
if (hasManifest) {
|
|
58
|
+
manifestOriginal = await read('dsh.plugin.json')
|
|
59
|
+
const manifest = JSON.parse(manifestOriginal)
|
|
60
|
+
manifest.engines ??= {}
|
|
61
|
+
manifest.engines.dsh = peerRange
|
|
62
|
+
manifest.version = pkg.version // version 以 package.json 为准,manifest 只镜像
|
|
63
|
+
manifestExpected = JSON.stringify(manifest, null, 2) + '\n'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── 3. 七语 README:管理块(支持清单 + 运行时已验证清单) ────────────────────
|
|
67
|
+
const BEGIN = '<!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->'
|
|
68
|
+
const END = '<!-- host-compat:end -->'
|
|
69
|
+
const versionList = supportedHosts.map((v) => `\`${v}\``).join(' ')
|
|
70
|
+
const LINES = '0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0'
|
|
71
|
+
const linesPerLang = {
|
|
72
|
+
'README.md': [
|
|
73
|
+
`- **支持的 DSH 宿主:** ${versionList}(覆盖 ${LINES} 六条线共 ${supportedHosts.length} 个 rc)`,
|
|
74
|
+
],
|
|
75
|
+
'README.en.md': [
|
|
76
|
+
`- **Supported DSH hosts:** ${versionList} (${supportedHosts.length} rc releases across lines ${LINES})`,
|
|
77
|
+
],
|
|
78
|
+
'README.de.md': [
|
|
79
|
+
`- **Unterstützte DSH-Hosts:** ${versionList} (${supportedHosts.length} RC über die Linien ${LINES})`,
|
|
80
|
+
],
|
|
81
|
+
'README.es.md': [
|
|
82
|
+
`- **Hosts DSH compatibles:** ${versionList} (${supportedHosts.length} rc en las líneas ${LINES})`,
|
|
83
|
+
],
|
|
84
|
+
'README.fr.md': [
|
|
85
|
+
`- **Hôtes DSH pris en charge :** ${versionList} (${supportedHosts.length} rc sur les lignes ${LINES})`,
|
|
86
|
+
],
|
|
87
|
+
'README.it.md': [
|
|
88
|
+
`- **Host DSH supportati:** ${versionList} (${supportedHosts.length} rc attraverso le linee ${LINES})`,
|
|
89
|
+
],
|
|
90
|
+
'README.ru.md': [
|
|
91
|
+
`- **Поддерживаемые хосты DSH:** ${versionList} (${supportedHosts.length} rc по линиям ${LINES})`,
|
|
92
|
+
],
|
|
93
|
+
}
|
|
94
|
+
// 矩阵跑绿清单(.compat-results/verified.json,由 scripts/test-host-compat.mjs 写出)
|
|
95
|
+
const verifiedUrl = new URL('.compat-results/verified.json', ROOT)
|
|
96
|
+
if (existsSync(verifiedUrl)) {
|
|
97
|
+
const { verified = [] } = JSON.parse(await readFile(verifiedUrl, 'utf8'))
|
|
98
|
+
if (verified.length > 0) {
|
|
99
|
+
const list = verified.map((v) => `\`${v}\``).join(', ')
|
|
100
|
+
const verifiedLine = {
|
|
101
|
+
'README.md': `- **运行时已验证:** ${list}(证据见 \`.compat-results/\`)`,
|
|
102
|
+
'README.en.md': `- **Runtime-verified:** ${list} — evidence in \`.compat-results/\``,
|
|
103
|
+
'README.de.md': `- **Zur Laufzeit verifiziert:** ${list} — Nachweise in \`.compat-results/\``,
|
|
104
|
+
'README.es.md': `- **Verificado en tiempo de ejecución:** ${list} — evidencia en \`.compat-results/\``,
|
|
105
|
+
'README.fr.md': `- **Vérifié à l'exécution :** ${list} — preuves dans \`.compat-results/\``,
|
|
106
|
+
'README.it.md': `- **Verificato a runtime:** ${list} — prove in \`.compat-results/\``,
|
|
107
|
+
'README.ru.md': `- **Проверено на этапе выполнения:** ${list} — доказательства в \`.compat-results/\``,
|
|
108
|
+
}
|
|
109
|
+
for (const [file, line] of Object.entries(verifiedLine)) linesPerLang[file].push(line)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const readmeProblems = []
|
|
113
|
+
for (const [file, lines] of Object.entries(linesPerLang)) {
|
|
114
|
+
const block = `${BEGIN}\n${lines.join('\n')}\n${END}`
|
|
115
|
+
const url = new URL(file, ROOT)
|
|
116
|
+
const content = await readFile(url, 'utf8')
|
|
117
|
+
const beginAt = content.indexOf(BEGIN)
|
|
118
|
+
if (beginAt === -1) {
|
|
119
|
+
// 插入点:第一个 `## ` 二级标题前(七语结构一致)
|
|
120
|
+
const at = content.search(/^## /m)
|
|
121
|
+
assert(at !== -1, `${file} 找不到插入锚点(第一个二级标题)`)
|
|
122
|
+
if (write) {
|
|
123
|
+
await writeFile(url, content.slice(0, at) + block + '\n\n' + content.slice(at))
|
|
124
|
+
console.log(`write ${file}: 插入管理块`)
|
|
125
|
+
} else {
|
|
126
|
+
readmeProblems.push(`${file} 缺少 host-compat 管理块`)
|
|
127
|
+
}
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
const endAt = content.indexOf(END, beginAt)
|
|
131
|
+
assert(endAt !== -1, `${file} 管理块缺少 end 标记`)
|
|
132
|
+
const current = content.slice(beginAt, endAt + END.length)
|
|
133
|
+
if (write) {
|
|
134
|
+
if (current !== block) {
|
|
135
|
+
await writeFile(url, content.slice(0, beginAt) + block + content.slice(endAt + END.length))
|
|
136
|
+
console.log(`write ${file}: 更新管理块`)
|
|
137
|
+
} else {
|
|
138
|
+
console.log(`ok ${file}: 管理块已是最新`)
|
|
139
|
+
}
|
|
140
|
+
} else if (current !== block) {
|
|
141
|
+
readmeProblems.push(`${file} 管理块内容需要同步`)
|
|
142
|
+
} else {
|
|
143
|
+
console.log(`ok ${file}: 管理块已是最新`)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ── 4. 汇总校验/写盘 ────────────────────────────────────────────────────────
|
|
148
|
+
if (write) {
|
|
149
|
+
if (pkgOriginal !== pkgExpected) {
|
|
150
|
+
await writeFile(pkgUrl, pkgExpected)
|
|
151
|
+
console.log('write package.json (engines.dsh + 12 dsh-* peers + cordis)')
|
|
152
|
+
} else console.log('ok package.json')
|
|
153
|
+
if (hasManifest) {
|
|
154
|
+
if (manifestOriginal !== manifestExpected) {
|
|
155
|
+
await writeFile(pluginJsonUrl, manifestExpected)
|
|
156
|
+
console.log('write dsh.plugin.json (engines.dsh + version)')
|
|
157
|
+
} else console.log('ok dsh.plugin.json')
|
|
158
|
+
} else console.log('skip dsh.plugin.json(本仓无插件 manifest)')
|
|
159
|
+
console.log('done --write 完成')
|
|
160
|
+
} else {
|
|
161
|
+
const jsonDrift = pkgOriginal !== pkgExpected ? ['package.json (engines.dsh / peerDependencies / cordis)'] : []
|
|
162
|
+
if (hasManifest && manifestOriginal !== manifestExpected) jsonDrift.push('dsh.plugin.json (engines.dsh / version)')
|
|
163
|
+
if (jsonDrift.length === 0 && readmeProblems.length === 0) {
|
|
164
|
+
console.log('ok 全部写点与 hosts.mjs 一致')
|
|
165
|
+
} else {
|
|
166
|
+
for (const p of [...jsonDrift, ...readmeProblems]) console.error(`drift ${p}`)
|
|
167
|
+
console.error('\n运行 node scripts/sync-hosts.mjs --write 修复')
|
|
168
|
+
process.exit(1)
|
|
169
|
+
}
|
|
170
|
+
}
|