@aiwayds/dsh-opentui 0.21.1 → 0.23.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.
@@ -218,7 +218,7 @@
218
218
  "settings.row.performanceUsage": "Performance & usage",
219
219
  "settings.row.performanceUsageNote": "N/A — this TUI has no performance/usage view",
220
220
  "settings.row.currentVersion": "Current version",
221
- "settings.row.activityPanelHeight": "Activity panel height",
221
+ "settings.row.activityPanelHeight": "Think display lines",
222
222
  "settings.jump.open": "Open {command}",
223
223
  "settings.jump.modelsNote": "the provider / API key / model-list page stays with /model in v1",
224
224
  "settings.jump.pluginsNote": "the plugin list and toggling live in the /plugins panel: enter/space toggles, d uninstalls (confirmed), i installs; some changes need a host restart",
@@ -545,6 +545,12 @@
545
545
  "overlay.ask.approvalTitle": "⚠ Approval: {name}",
546
546
  "overlay.ask.allow": "allow",
547
547
  "overlay.ask.reject": "reject",
548
+ "overlay.ask.invalidatedTitle": "⚠ Invalidated",
549
+ "overlay.ask.invalidated": "This request is no longer valid: {reason}",
550
+ "overlay.ask.invalidated.disconnected": "Connection lost; the bridge process has exited",
551
+ "overlay.ask.invalidatedAck": "OK",
552
+ "overlay.ask.allowAlways": "always",
553
+ "overlay.ask.allowSession": "session",
548
554
  "overlay.ask.reviewRow": "⏎ Review answers",
549
555
  "overlay.ask.reviewTitle": "Review answers",
550
556
  "overlay.ask.submitRow": "⏎ Submit answers",
@@ -611,7 +617,6 @@
611
617
  "turn.stop.confirmMessage": "Stop {parts} now? Queued prompts stay and the session remains resumable.",
612
618
  "turn.stop.confirmLabel": "stop",
613
619
  "turn.stop.cancelLabel": "keep running",
614
- "footer.messages": "💬 {n} msgs",
615
620
  "footer.msgs.one": "💬 {n} msg",
616
621
  "footer.msgs.many": "💬 {n} msgs",
617
622
  "footer.hint.quit": "ctrl+c ×2 quit",
@@ -913,5 +918,26 @@
913
918
  "dialog.mcp.details.integration": "\nIntegration: {id}",
914
919
  "composer.placeholder": "Type a message (enter send, alt+enter newline)",
915
920
  "hero.plugins.count": "plugins {count}",
916
- "hero.plugins.more": "… +{count} more"
921
+ "hero.plugins.more": "… +{count} more",
922
+ "error.sessionLocked": "writer-held: session \"{id}\" is already open in another process (holding session: {holder}). Close that instance and retry.",
923
+ "error.sessionLockedNoHolder": "writer-held: a session is already open in another process (holding session unknown). Close that instance and retry.",
924
+ "notice.permission.unavailable": "Approval channel unavailable: tool calls requiring approval will be denied (fail-closed)",
925
+ "notice.permission.reason.no-provider": "no approval provider registered",
926
+ "notice.permission.reason.bridge-offline": "bridge not connected",
927
+ "notice.permission.reason.ask-no-provider": "ask.request answered unavailable (ASK_CHANNEL_UNAVAILABLE)",
928
+ "recovery.transient": "Connection lost - reconnecting...",
929
+ "recovery.recovered": "Reconnected - {count} event(s) caught up",
930
+ "recovery.failed.reason": "Recovery failed: {reason}",
931
+ "recovery.locked": "Session is writer-held by another process",
932
+ "recovery.locked.reason": "Session is writer-held by another process: {reason}",
933
+ "recovery.locked.holder": "Session is writer-held by another process: {reason} (held by {holder})",
934
+ "recovery.cooldown": "Cooling down - {remainingMs} ms left",
935
+ "recovery.action.reconnect": "Reconnect [R]",
936
+ "recovery.action.retry": "Retry [R]",
937
+ "recovery.action.newSession": "New session",
938
+ "recovery.action.quit": "Quit",
939
+ "recovery.command.title": "Reconnect bridge session",
940
+ "recovery.composer.disabled": "Reconnecting...",
941
+ "recovery.turn.interrupted": "Interrupted - connection lost mid-turn (local marker, turn {turnId})",
942
+ "recovery.input.unconfirmed": "Unconfirmed input - not acknowledged by the host yet"
917
943
  }
@@ -218,7 +218,7 @@
218
218
  "settings.row.performanceUsage": "性能与用量",
219
219
  "settings.row.performanceUsageNote": "不适用 — 本 TUI 没有性能/用量视图",
220
220
  "settings.row.currentVersion": "当前版本",
221
- "settings.row.activityPanelHeight": "活动面板高度",
221
+ "settings.row.activityPanelHeight": "思考显示行数",
222
222
  "settings.jump.open": "打开 {command}",
223
223
  "settings.jump.modelsNote": "provider / API 密钥 / 模型列表页在 v1 中仍由 /model 负责",
224
224
  "settings.jump.pluginsNote": "plugin 列表和开关在 /plugins 面板:enter/space 切换,d 卸载(需确认),i 安装;部分变更需重启 host",
@@ -545,6 +545,12 @@
545
545
  "overlay.ask.approvalTitle": "⚠ 审批:{name}",
546
546
  "overlay.ask.allow": "允许",
547
547
  "overlay.ask.reject": "拒绝",
548
+ "overlay.ask.invalidatedTitle": "⚠ 已失效",
549
+ "overlay.ask.invalidated": "此请求已失效:{reason}",
550
+ "overlay.ask.invalidated.disconnected": "连接已断开,bridge 进程已终止",
551
+ "overlay.ask.invalidatedAck": "知道了",
552
+ "overlay.ask.allowAlways": "始终允许",
553
+ "overlay.ask.allowSession": "本会话允许",
548
554
  "overlay.ask.reviewRow": "⏎ 查看答案",
549
555
  "overlay.ask.reviewTitle": "确认答案",
550
556
  "overlay.ask.submitRow": "⏎ 提交答案",
@@ -598,7 +604,6 @@
598
604
  "overlay.widgets.todosHeader": "● 待办({done}/{total})",
599
605
  "overlay.widgets.todosShowing": "显示 {ranges}",
600
606
  "overlay.widgets.todosSummary": "待办 [✓]{done}/{total}",
601
- "footer.messages": "💬 {n} 条消息",
602
607
  "footer.msgs.one": "💬 {n} 条消息",
603
608
  "footer.msgs.many": "💬 {n} 条消息",
604
609
  "footer.hint.send.idle": "enter 发送",
@@ -913,5 +918,26 @@
913
918
  "dialog.mcp.details.integration": "\n集成:{id}",
914
919
  "composer.placeholder": "输入消息(enter 发送,alt+enter 换行)",
915
920
  "hero.plugins.count": "插件 {count}",
916
- "hero.plugins.more": "… 还有 {count} 个"
921
+ "hero.plugins.more": "… 还有 {count} 个",
922
+ "error.sessionLocked": "writer-held:会话 \"{id}\" 已在另一进程中打开(持有会话:{holder})。请关闭该实例后重试。",
923
+ "error.sessionLockedNoHolder": "writer-held:某会话已在另一进程中打开(持有会话未知)。请关闭该实例后重试。",
924
+ "notice.permission.unavailable": "审批通道不可用:需要审批的工具调用将被拒绝(fail-closed)",
925
+ "notice.permission.reason.no-provider": "未注册审批 provider",
926
+ "notice.permission.reason.bridge-offline": "bridge 未连接",
927
+ "notice.permission.reason.ask-no-provider": "ask.request 应答为不可用(ASK_CHANNEL_UNAVAILABLE)",
928
+ "recovery.transient": "连接已断开,正在恢复…",
929
+ "recovery.recovered": "已恢复连接,补齐 {count} 条事件",
930
+ "recovery.failed.reason": "恢复连接失败:{reason}",
931
+ "recovery.locked": "会话已被另一进程持有(writer-held)",
932
+ "recovery.locked.reason": "会话已被另一进程持有(writer-held):{reason}",
933
+ "recovery.locked.holder": "会话已被另一进程持有(writer-held):{reason}(持有会话:{holder})",
934
+ "recovery.cooldown": "冷却中,还剩 {remainingMs} ms",
935
+ "recovery.action.reconnect": "重连 [R]",
936
+ "recovery.action.retry": "重试 [R]",
937
+ "recovery.action.newSession": "新会话",
938
+ "recovery.action.quit": "退出",
939
+ "recovery.command.title": "重连桥接会话",
940
+ "recovery.composer.disabled": "正在恢复连接…",
941
+ "recovery.turn.interrupted": "已中断 - turn 在途时连接断开(本地标记,turn {turnId})",
942
+ "recovery.input.unconfirmed": "未确认输入 - 宿主尚未确认"
917
943
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiwayds/dsh-opentui",
3
- "version": "0.21.1",
3
+ "version": "0.23.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  "bin",
16
16
  "scripts",
17
17
  "dist/client",
18
+ "dist/bridge",
18
19
  "dist/scripts",
19
20
  "dist/locales",
20
21
  "dist/host-launch.mjs",
@@ -29,7 +30,7 @@
29
30
  "scripts": {
30
31
  "client": "bun src/client-entry.tsx",
31
32
  "typecheck": "tsc --noEmit",
32
- "prepack": "bun ../../scripts/build-client.mjs && bun ../../scripts/verify-pack-locales.mjs && node scripts/pack-meta.mjs"
33
+ "prepack": "bun ../../scripts/build-bridge.mjs && bun ../../scripts/build-client.mjs && bun ../../scripts/verify-pack-locales.mjs && node scripts/pack-meta.mjs"
33
34
  },
34
35
  "dependencies": {
35
36
  "@opentui/core": "0.8.1",
@@ -0,0 +1,13 @@
1
+ /** Type declarations for bridge-failfast-text.mjs (shared by the client TS
2
+ * program and the provision script). Kept beside the .mjs so `tsc` with
3
+ * moduleResolution: bundler resolves the string constants without allowJs. */
4
+
5
+ export declare const BRIDGE_REPAIR_COMMAND: string
6
+ export declare const BRIDGE_APPEND_PRESET_NOTICE: string
7
+ export declare const BRIDGE_LEGACY_REMOTE_HINT: string
8
+ export declare const BRIDGE_REPAIR_HINT: string
9
+
10
+ export declare function formatBridgeFailFastMessage(
11
+ diagnosis: string,
12
+ repairCommand?: string,
13
+ ): string
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Single source of the inproc bridge fail-fast message text (P0 3-element fix).
3
+ *
4
+ * Both failure paths MUST print the same three elements (T11 original:
5
+ * "错误自包含诊断 + 修复命令 + 模式说明"):
6
+ * 1. diagnosis — what failed, with expected/actual values
7
+ * 2. repair command — the concrete command to fix it
8
+ * 3. mode notice — append-system is injected via the bridge section;
9
+ * presets are standard only (M3 landed)
10
+ *
11
+ * The third element used to say append was unavailable in this mode. That was
12
+ * true before M3 but is now false: M3-04 registers the append section through
13
+ * session.open setup, and M3-05b keeps the legacy append preset id as inert
14
+ * metadata (the `standard` mapping from 8e0e847 was reverted in a45a052) —
15
+ * append text is injected by the bridge section, not by a preset. The notice
16
+ * is kept (it is still useful context) with corrected semantics — do not
17
+ * restore the stale "no append" claim.
18
+ *
19
+ * They used to be split across two hard-coded sources that never met:
20
+ * - `src/client/seam-bootstrap.ts` BridgeBootstrapError (handshake path) had
21
+ * all three via `formatBridgeBootstrapMessage`;
22
+ * - `scripts/provision-inproc-profile.mjs` ProvisionError (fingerprint path)
23
+ * had diagnosis + repair hint but NO mode notice.
24
+ *
25
+ * This module lives under `scripts/` (the only source dir the npm `files`
26
+ * allowlist publishes) so BOTH the shipped provision script and the bundled
27
+ * client can import it. Do not re-declare these strings in either consumer.
28
+ */
29
+
30
+ /** Concrete repair command carried by every bridge bootstrap/provision error. */
31
+ export const BRIDGE_REPAIR_COMMAND = 'dsh-opentui --repair-bridge'
32
+
33
+ /** The current-mode append/preset half of the error text (T11 #3, rewritten in M3-08). */
34
+ export const BRIDGE_APPEND_PRESET_NOTICE =
35
+ 'inproc bridge mode injects append-system via the bridge section; presets are standard only.'
36
+
37
+ /** The escape-hatch line carried by EVERY bridge failure: a launch-level opt
38
+ * out of the default inproc bridge back to the legacy remote thin client. Kept
39
+ * as its own constant so the host gate and the shared repair hint cannot drift. */
40
+ export const BRIDGE_LEGACY_REMOTE_HINT =
41
+ 'To keep the legacy remote thin client for this launch: DSH_OPENTUI_INPROC=0'
42
+
43
+ /** The repair element with the link-vs-content caveat (provision-script wording). */
44
+ export const BRIDGE_REPAIR_HINT =
45
+ `Run \`${BRIDGE_REPAIR_COMMAND}\` to rebuild the bridge symlink / manifest (it fixes links, not corrupted artifact contents).\n${BRIDGE_LEGACY_REMOTE_HINT}`
46
+
47
+ /**
48
+ * Compose the three elements into one copy-pasteable, self-contained message.
49
+ * `diagnosis` is element 1 (already carrying expected/actual where available);
50
+ * element 2 is the shared repair command; element 3 is the shared mode notice.
51
+ */
52
+ export function formatBridgeFailFastMessage(diagnosis, repairCommand = BRIDGE_REPAIR_COMMAND) {
53
+ return [diagnosis, `Fix: ${repairCommand}`, BRIDGE_APPEND_PRESET_NOTICE].join('\n')
54
+ }
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Single source of truth for the in-process bridge's host-version compatibility.
3
+ *
4
+ * Two consumers, one policy:
5
+ * - scripts/build-bridge.mjs injects HOST_PEER_RANGE into the shipped bridge
6
+ * manifest, which is what the host's `evaluatePluginCompatibility` reads.
7
+ * - scripts/provision-inproc-profile.mjs gates startup: it detects the
8
+ * running host, fails loud when it is outside the window (the host only
9
+ * records an incompatible bundle in `skippedBundles` and prints nothing on
10
+ * this path), and grants the exact-version exemption otherwise.
11
+ *
12
+ * No `semver` import: the shipped provision script runs under plain Node in a
13
+ * published package with no workspace node_modules. The comparison below
14
+ * mirrors `semver.satisfies(v, '>=0.2.2-rc.3 <0.3.0', { includePrerelease: true })`
15
+ * for the canonical versions this project deals with (numeric core + dotted
16
+ * prerelease identifiers).
17
+ */
18
+ import { spawnSync } from 'node:child_process'
19
+ import { readFileSync, renameSync, writeFileSync } from 'node:fs'
20
+ import { join } from 'node:path'
21
+
22
+ /** Host peer whose version expresses the dsh runtime requirement. */
23
+ export const HOST_PEER_NAME = '@deepseek-ai/dsh-base'
24
+
25
+ /**
26
+ * Supported host window. rc.3 is the floor the bridge was built against; the
27
+ * rc.3 -> rc.4 surface the bridge consumes is byte-identical (dsh-base and the
28
+ * service packages' `lib/types/index.d.ts` diffs are empty — see the commit
29
+ * message). The <0.3.0 cap turns a future major bump into a loud provisioning
30
+ * failure instead of a silent plugin skip.
31
+ */
32
+ export const HOST_PEER_RANGE = '>=0.2.2-rc.3 <0.3.0'
33
+
34
+ /** Host-owned file that carries exact version exemptions (profile-local). */
35
+ export const COMPATIBILITY_FILENAME = 'compatibility.json'
36
+
37
+ /**
38
+ * Explicit override for host-version detection. Intended for tests and for a
39
+ * caller that already knows the exact runtime; empty/unset means auto-detect
40
+ * via `dsh --version`.
41
+ */
42
+ export const HOST_VERSION_ENV = 'DSH_OPENTUI_HOST_VERSION'
43
+
44
+ // --- Minimal semver ---------------------------------------------------------
45
+
46
+ /** Parse a canonical semver; return null for anything else (ranges, prefixes, garbage). */
47
+ function parseVersion(value) {
48
+ if (typeof value !== 'string') return null
49
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$/.exec(value.trim())
50
+ if (match === null) return null
51
+ const prerelease = match[4] === undefined ? [] : match[4].split('.')
52
+ if (prerelease.some((id) => /^\d+$/.test(id) && id.length > 1 && id.startsWith('0'))) return null
53
+ return {
54
+ major: Number(match[1]),
55
+ minor: Number(match[2]),
56
+ patch: Number(match[3]),
57
+ prerelease,
58
+ build: match[5] ?? '',
59
+ }
60
+ }
61
+
62
+ /** Whether a string is a canonical exact version (the host only grants exact keys). */
63
+ export function isExactVersion(value) {
64
+ if (typeof value !== 'string') return false
65
+ const parsed = parseVersion(value)
66
+ if (parsed === null) return false
67
+ const canonical = `${parsed.major}.${parsed.minor}.${parsed.patch}${parsed.prerelease.length === 0 ? '' : `-${parsed.prerelease.join('.')}`}${parsed.build === '' ? '' : `+${parsed.build}`}`
68
+ return value === canonical
69
+ }
70
+
71
+ function compareIdentifier(a, b) {
72
+ const aNumeric = /^\d+$/.test(a)
73
+ const bNumeric = /^\d+$/.test(b)
74
+ if (aNumeric && bNumeric) return Math.sign(Number(a) - Number(b))
75
+ if (aNumeric) return -1 // numeric identifiers rank below non-numeric ones
76
+ if (bNumeric) return 1
77
+ return a < b ? -1 : a > b ? 1 : 0
78
+ }
79
+
80
+ /** Compare two canonical versions: -1 / 0 / 1. Throws on malformed input. */
81
+ export function compareVersions(left, right) {
82
+ const a = parseVersion(left)
83
+ const b = parseVersion(right)
84
+ if (a === null || b === null) {
85
+ throw new Error(`cannot compare non-semver values ${JSON.stringify(left)} / ${JSON.stringify(right)}`)
86
+ }
87
+ for (const field of ['major', 'minor', 'patch']) {
88
+ if (a[field] !== b[field]) return a[field] < b[field] ? -1 : 1
89
+ }
90
+ // A version with a prerelease ranks below the corresponding release.
91
+ if (a.prerelease.length === 0 && b.prerelease.length > 0) return 1
92
+ if (a.prerelease.length > 0 && b.prerelease.length === 0) return -1
93
+ for (let i = 0; i < Math.max(a.prerelease.length, b.prerelease.length); i++) {
94
+ if (i >= a.prerelease.length) return -1
95
+ if (i >= b.prerelease.length) return 1
96
+ const cmp = compareIdentifier(a.prerelease[i], b.prerelease[i])
97
+ if (cmp !== 0) return cmp
98
+ }
99
+ return 0
100
+ }
101
+
102
+ /** The floor and cap of HOST_PEER_RANGE, kept literal here and pinned by tests. */
103
+ export const SUPPORTED_FLOOR = '0.2.2-rc.3'
104
+ export const SUPPORTED_CAP = '0.3.0'
105
+
106
+ /**
107
+ * Whether `version` is inside the supported host window. Mirrors the host's
108
+ * `semver.satisfies(version, HOST_PEER_RANGE, { includePrerelease: true })`,
109
+ * so 0.3.0-rc.1 is still inside and 0.3.0 (and 0.2.2-rc.2) are outside.
110
+ */
111
+ export function isHostVersionSupported(version) {
112
+ if (parseVersion(version) === null) return false
113
+ return compareVersions(version, SUPPORTED_FLOOR) >= 0 && compareVersions(version, SUPPORTED_CAP) < 0
114
+ }
115
+
116
+ // --- Host version detection -------------------------------------------------
117
+
118
+ /** Read the exact runtime version from `dsh --version` (the host's own app-boot version). */
119
+ export function detectHostVersion({ env = process.env, spawn = spawnSync } = {}) {
120
+ const override = env[HOST_VERSION_ENV]
121
+ const raw = override !== undefined && override.trim() !== '' ? override.trim() : fromDshCli(spawn)
122
+ if (raw === undefined || raw === '') {
123
+ throw new Error(
124
+ `could not determine the running dsh host version via \`dsh --version\` (or ${HOST_VERSION_ENV}); `
125
+ + 'refusing to provision because a version mismatch would skip the bridge without a usable error',
126
+ )
127
+ }
128
+ if (!isExactVersion(raw)) {
129
+ throw new Error(`dsh host version ${JSON.stringify(raw)} is not an exact semantic version`)
130
+ }
131
+ return raw
132
+ }
133
+
134
+ function fromDshCli(spawn) {
135
+ let result
136
+ try {
137
+ result = spawn('dsh', ['--version'], { encoding: 'utf8', timeout: 5000 })
138
+ } catch (error) {
139
+ return undefined
140
+ }
141
+ if (result?.error !== undefined || result?.status !== 0) return undefined
142
+ const line = String(result.stdout ?? '')
143
+ .split(/\r?\n/)
144
+ .map((part) => part.trim())
145
+ .find(Boolean)
146
+ return line === undefined ? undefined : line.replace(/^v/, '')
147
+ }
148
+
149
+ // --- Profile-local exemption ------------------------------------------------
150
+
151
+ function isPlainObject(value) {
152
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
153
+ }
154
+
155
+ /**
156
+ * Read the profile's compatibility file the same way the host does, but treat
157
+ * anything malformed as fatal: a file the host would silently ignore is
158
+ * exactly how the bridge ends up skipped with no explanation.
159
+ */
160
+ export function readExemptions(profileDir) {
161
+ const filename = join(profileDir, COMPATIBILITY_FILENAME)
162
+ let text
163
+ try {
164
+ text = readFileSync(filename, 'utf8')
165
+ } catch (error) {
166
+ if (error?.code === 'ENOENT') return { exemptions: {}, warnings: [] }
167
+ throw new Error(`${filename} cannot be read: ${String(error)}`)
168
+ }
169
+ let value
170
+ try {
171
+ value = JSON.parse(text)
172
+ } catch (error) {
173
+ throw new Error(`${filename} is not valid JSON (${String(error)}); repair it by hand before provisioning`)
174
+ }
175
+ if (!isPlainObject(value)) {
176
+ throw new Error(`${filename} must map exact package@version keys to arrays of exact dsh versions`)
177
+ }
178
+ const exemptions = {}
179
+ const warnings = []
180
+ for (const [key, versions] of Object.entries(value)) {
181
+ const separator = key.lastIndexOf('@')
182
+ const name = separator > 0 ? key.slice(0, separator) : ''
183
+ const version = separator > 0 ? key.slice(separator + 1) : ''
184
+ if (!/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(name) || !isExactVersion(version)) {
185
+ warnings.push(`${JSON.stringify(key)} is not an exact package-name@version key`)
186
+ continue
187
+ }
188
+ if (!Array.isArray(versions) || versions.some((item) => !isExactVersion(item))) {
189
+ warnings.push(`${key} must contain a list of exact dsh versions`)
190
+ continue
191
+ }
192
+ exemptions[key] = versions
193
+ }
194
+ return { exemptions, warnings }
195
+ }
196
+
197
+ /**
198
+ * Grant the exact-version exemption for one plugin only when the host is in
199
+ * the supported window. Never called for an unsupported host, so --accept-risk
200
+ * can never rubber-stamp a real incompatibility.
201
+ * @returns { changed, key } — `changed` is false when the grant already exists.
202
+ */
203
+ export function ensureHostExemption({ profileDir, packageName, packageVersion, hostVersion }) {
204
+ if (!isExactVersion(packageVersion) || !isExactVersion(hostVersion)) {
205
+ throw new Error('a version exemption requires exact package and dsh versions')
206
+ }
207
+ const key = `${packageName}@${packageVersion}`
208
+ const { exemptions, warnings } = readExemptions(profileDir)
209
+ if (warnings.length > 0) {
210
+ throw new Error(
211
+ `${join(profileDir, COMPATIBILITY_FILENAME)} contains records this provisioner will not rewrite: ${warnings.join('; ')}. Repair the file by hand.`,
212
+ )
213
+ }
214
+ if (exemptions[key]?.includes(hostVersion) === true) return { changed: false, key }
215
+ const next = {
216
+ ...exemptions,
217
+ [key]: [...new Set([...(exemptions[key] ?? []), hostVersion])],
218
+ }
219
+ const filename = join(profileDir, COMPATIBILITY_FILENAME)
220
+ const tmp = `${filename}.tmp-${process.pid}-${Date.now()}`
221
+ writeFileSync(tmp, `${JSON.stringify(next, undefined, 2)}\n`, { mode: 0o600 })
222
+ renameSync(tmp, filename)
223
+ return { changed: true, key }
224
+ }