@aiwayds/dsh-opentui 0.27.2 → 0.28.1
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 +39 -15
- package/README.md +59 -178
- package/bin/dsh-opentui.mjs +70 -258
- package/bin/lib/launcher.mjs +36 -187
- package/dist/client/index.js +7636 -16519
- package/dist/client/index.js.map +28 -53
- package/dist/locales/en.json +15 -2
- package/dist/locales/zh-CN.json +15 -2
- package/package.json +7 -11
- package/scripts/lib/companion-policy.mjs +16 -0
- package/scripts/lib/inproc-companions.mjs +128 -38
- package/scripts/lib/migration-io.mjs +231 -0
- package/scripts/lib/migration.mjs +724 -0
- package/scripts/lib/patch-ownership-state.mjs +42 -0
- package/scripts/lib/patch-ownership.mjs +1428 -0
- package/scripts/lib/profile-lock.mjs +185 -0
- package/scripts/lib/profile-name.d.mts +1 -0
- package/scripts/lib/profile-name.mjs +2 -0
- package/scripts/lib/provision-run-lock.mjs +223 -0
- package/scripts/provision-inproc-profile.mjs +634 -286
- package/scripts/upgrade.mjs +445 -1110
- package/dist/host-launch.mjs +0 -1293
- package/dist/host-launch.mjs.map +0 -19
- package/dist/scripts/idle-reaper.mjs +0 -173
- package/dist/watchdog.mjs +0 -476
- package/dist/watchdog.mjs.map +0 -16
- package/scripts/e2e-client.mjs +0 -1122
- package/scripts/e2e-sweep.mjs +0 -932
- package/scripts/idle-reaper.mjs +0 -173
- package/scripts/lib/provision-plan.mjs +0 -899
- package/scripts/lib/provision-state.mjs +0 -294
- package/scripts/lib/upgrade-plan.mjs +0 -489
- package/scripts/provision-opentui-profile.mjs +0 -806
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The patch-ownership sidecar: `profiles/<p>/.patch-ownership.json`.
|
|
3
|
+
*
|
|
4
|
+
* `ancestor` is the TEMPLATE projection adopted by the previous converge pass
|
|
5
|
+
* (never the bytes we wrote) — see design 06 R1/§4.3.1. A missing or corrupt
|
|
6
|
+
* sidecar degrades to base-unknown (carry current), so the file only affects
|
|
7
|
+
* merge direction, never the written values. Written inside the same
|
|
8
|
+
* `package.json.lock` critical section as the patch, tmp+rename, mode 0600.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
12
|
+
import { join } from 'node:path'
|
|
13
|
+
|
|
14
|
+
export const STATE_NAME = '.patch-ownership.json'
|
|
15
|
+
|
|
16
|
+
export function statePath(profileDir) {
|
|
17
|
+
return join(profileDir, STATE_NAME)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** undefined for ENOENT / corrupt / unknown version (deliberately non-throwing). */
|
|
21
|
+
export function readState(profileDir) {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(readFileSync(statePath(profileDir), 'utf8'))
|
|
24
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return undefined
|
|
25
|
+
if (parsed.version !== 1 || parsed.rows === null || typeof parsed.rows !== 'object' || Array.isArray(parsed.rows)) return undefined
|
|
26
|
+
return parsed
|
|
27
|
+
} catch {
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function writeState(profileDir, state, { now = () => new Date().toISOString(), pid = process.pid, stamp = Date.now() } = {}) {
|
|
33
|
+
if (!state || state.version !== 1 || !state.rows) return false
|
|
34
|
+
const path = statePath(profileDir)
|
|
35
|
+
const outgoing = { ...state, writtenAt: now() }
|
|
36
|
+
const tmp = `${path}.tmp-${pid}-${stamp}`
|
|
37
|
+
writeFileSync(tmp, `${JSON.stringify(outgoing, null, 2)}\n`, { mode: 0o600 })
|
|
38
|
+
renameSync(tmp, path)
|
|
39
|
+
return true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default { STATE_NAME, statePath, readState, writeState }
|