dsh-session-sync 0.2.27 → 0.2.28
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 +11 -0
- package/README.md +1 -1
- package/lib/encrypted.mjs +16 -7
- package/lib/engine.mjs +28 -9
- package/lib/mirror.mjs +136 -8
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.28] - 2026-10-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Delete/modify conflicts now keep both sides instead of aborting a pull.** When one side deletes and the other modifies, the modified bytes are preserved (remote side as a fork file when present), the deletion intent is honored, and the merge continues; the earlier code called `checkout --ours/--theirs` on a missing stage and aborted the whole pull.
|
|
8
|
+
- **Pulled-only sessions are never deleted by the next local sync.** `mirrorSessionRoot` records the source snapshot under `.git/` and only deletes files it previously mirrored from the local `sessionRoot`; a file that arrived via pull is left untouched, and an unknown snapshot deletes nothing.
|
|
9
|
+
- **Remote deletions reach the non-owner device without being resurrected.** `restoreSessionRoot` records hashes of copies it created; a later pull prunes a pulled copy only while its bytes still match the recorded hash. A user-edited copy is kept and pushes normally.
|
|
10
|
+
- The three-way tree merge also tolerates a missing side instead of putting `undefined` into the merged tree.
|
|
11
|
+
|
|
12
|
+
Closes the conflict-resolution half of PR #14. The redaction half landed in 0.2.27.
|
|
13
|
+
|
|
3
14
|
## [0.2.27] - 2026-10-18
|
|
4
15
|
|
|
5
16
|
### Fixed
|
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ Example override in your profile patch:
|
|
|
182
182
|
|
|
183
183
|
## Security boundaries
|
|
184
184
|
|
|
185
|
-
- **Never silently overwrite.** The append-only three-way merge keeps both sides on any divergence; fork files are never deleted, and git never force-pushes, resets, rebases, or switches branches.
|
|
185
|
+
- **Never silently overwrite.** The append-only three-way merge keeps both sides on any divergence, including delete/modify (modified bytes kept, deletion intent honored); fork files are never deleted, and git never force-pushes, resets, rebases, or switches branches.
|
|
186
186
|
- **Path containment.** Files are mirrored as opaque bytes with symlinks refused and every joined path containment-checked (`PATH_UNSAFE` fails loud).
|
|
187
187
|
- **Sanitized output.** Remote-URL credentials, tokens, and `key=value` secrets are redacted before reaching the model or the log; path display refuses anything outside its root.
|
|
188
188
|
- **No credential storage.** The plugin stores no credentials; git credentials live in your normal git credential helper. age keys are read from paths you configure (`ageIdentity`); keys never enter the sync repository.
|
package/lib/encrypted.mjs
CHANGED
|
@@ -155,16 +155,25 @@ export function mergeTrees(base, ours, theirs, stamp, deviceShort) {
|
|
|
155
155
|
let diverged = 0
|
|
156
156
|
const keys = new Set([...base.keys(), ...ours.keys(), ...theirs.keys()])
|
|
157
157
|
for (const rel of keys) {
|
|
158
|
-
const
|
|
158
|
+
const remote = theirs.get(rel)
|
|
159
|
+
const verdict = classifyPath(base.get(rel), ours.get(rel), remote)
|
|
160
|
+
// 远端删除(theirs 无字节)是这棵树里唯一「没有远端内容可留存」的分歧:
|
|
161
|
+
// 采纳删除=从合并树移除,其余=保留 ours 并计分歧。绝不把 undefined 塞进
|
|
162
|
+
// merged —— writeTree 对每个条目 fs.writeFile,undefined 会直接抛错。
|
|
159
163
|
if (verdict.kind === MERGE_KINDS.THEIRS_ONLY) {
|
|
160
|
-
|
|
164
|
+
if (remote === undefined) merged.delete(rel)
|
|
165
|
+
else merged.set(rel, remote)
|
|
161
166
|
adopted += 1
|
|
162
167
|
} else if (verdict.forkTheirs) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
if (remote === undefined) {
|
|
169
|
+
diverged += 1
|
|
170
|
+
} else {
|
|
171
|
+
const forkRel = path.posix.join(path.posix.dirname(rel), forkFileName(path.posix.basename(rel), stamp, deviceShort))
|
|
172
|
+
merged.set(forkRel, remote)
|
|
173
|
+
forks.push(forkRel)
|
|
174
|
+
if (verdict.kind === MERGE_KINDS.APPEND_BOTH) appended += 1
|
|
175
|
+
else diverged += 1
|
|
176
|
+
}
|
|
168
177
|
}
|
|
169
178
|
// identical / ours-only:保留 ours(已在 merged 中)。
|
|
170
179
|
}
|
package/lib/engine.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { promises as fs } from 'node:fs'
|
|
|
12
12
|
import path from 'node:path'
|
|
13
13
|
import { MERGE_KINDS, MIRROR_DIR, DEVICE_FILE } from './constants.mjs'
|
|
14
14
|
import { planMerge } from './merge.mjs'
|
|
15
|
-
import { mirrorSessionRoot, restoreSessionRoot, ensureDeviceFile } from './mirror.mjs'
|
|
15
|
+
import { mirrorSessionRoot, restoreSessionRoot, pruneRestoredSessions, ensureDeviceFile } from './mirror.mjs'
|
|
16
16
|
import { collectStatus } from './status.mjs'
|
|
17
17
|
import { forkFileName } from './paths.mjs'
|
|
18
18
|
import { messageOf, SyncError } from './errors.mjs'
|
|
@@ -218,12 +218,15 @@ export class SyncEngine {
|
|
|
218
218
|
await this.#deps.git.addAll()
|
|
219
219
|
}
|
|
220
220
|
const newHead = await this.#deps.git.commitMerge()
|
|
221
|
+
const mirrorRoot = path.join(this.#deps.repoDir, MIRROR_DIR)
|
|
222
|
+
const pruned = await pruneRestoredSessions({ repoDir: this.#deps.repoDir, mirrorRoot, sessionRoot: this.#deps.sessionRoot })
|
|
221
223
|
const restored = await restoreSessionRoot({
|
|
222
|
-
|
|
224
|
+
repoDir: this.#deps.repoDir,
|
|
225
|
+
mirrorRoot,
|
|
223
226
|
sessionRoot: this.#deps.sessionRoot,
|
|
224
227
|
})
|
|
225
228
|
this.#deps.reportMeta({ lastPullAt: Date.now() })
|
|
226
|
-
this.#deps.logger.info(`sync pull ok: merged remote head ${remoteHead} → ${newHead ?? ''} (${result.appended} appended-both, ${result.diverged} diverged, ${result.forks.length} forks, ${restored.restored} restored)`)
|
|
229
|
+
this.#deps.logger.info(`sync pull ok: merged remote head ${remoteHead} → ${newHead ?? ''} (${result.appended} appended-both, ${result.diverged} diverged, ${result.forks.length} forks, ${restored.restored} restored, ${pruned.pruned.length} pulled-deletions)`)
|
|
227
230
|
if (result.forks.length > 0) this.#deps.onForks(result.forks)
|
|
228
231
|
return {
|
|
229
232
|
ok: true,
|
|
@@ -241,6 +244,10 @@ export class SyncEngine {
|
|
|
241
244
|
/**
|
|
242
245
|
* 冲突解决:逐路径分类 → ours/theirs 检出 → 远端侧留存为 fork 文件 →
|
|
243
246
|
* 全量暂存(提交由调用方落合并提交)。失败时 abortMerge 恢复。
|
|
247
|
+
*
|
|
248
|
+
* 删除/修改冲突(一侧删除、另一侧修改)同样走 keep-both:git 只为存在的一侧
|
|
249
|
+
* 登记 stage,缺失的一侧按「该侧删除了该文件」解释——删除意图保留,另一侧
|
|
250
|
+
* 按既有规则存续(远端内容仍以 fork 文件留存)。绝不因缺 stage 而中止整次 pull。
|
|
244
251
|
* @returns {Promise<{adopted: number, appended: number, diverged: number, forks: string[]}>}
|
|
245
252
|
*/
|
|
246
253
|
async #resolveConflicts() {
|
|
@@ -256,6 +263,8 @@ export class SyncEngine {
|
|
|
256
263
|
entries.push({ path: conflict.path, base, ours, theirs })
|
|
257
264
|
}
|
|
258
265
|
const { resolutions, summary } = planMerge(entries)
|
|
266
|
+
/** 路径 → ours/theirs 字节;某侧缺失即该侧删除了该文件(git 不登记其 stage)。 */
|
|
267
|
+
const sides = new Map(entries.map(entry => [entry.path, entry]))
|
|
259
268
|
const forks = []
|
|
260
269
|
const now = new Date()
|
|
261
270
|
// 严格 14 位 UTC 戳(yyyyMMddHHmmss):与 lib/encrypted.mjs 同口径剔除 ISO
|
|
@@ -263,23 +272,33 @@ export class SyncEngine {
|
|
|
263
272
|
// forkFileName 的 /^\d{14}$/ 失配并静默回退到纪元戳。
|
|
264
273
|
const stamp = now.toISOString().replace(/[-:T]/gu, '').slice(0, 14)
|
|
265
274
|
for (const resolution of resolutions) {
|
|
275
|
+
const side = sides.get(resolution.path)
|
|
276
|
+
const hasOurs = side?.ours !== undefined
|
|
277
|
+
const hasTheirs = side?.theirs !== undefined
|
|
278
|
+
const absolute = path.join(this.#deps.repoDir, ...resolution.path.split('/'))
|
|
279
|
+
// `checkout --ours/--theirs` 对缺失的 stage 会失败(`does not have
|
|
280
|
+
// our/their version`),因此每一侧都先看它在冲突里是否存在。
|
|
266
281
|
if (resolution.adoptTheirs) {
|
|
267
|
-
await this.#deps.git.checkoutStage('theirs', resolution.path)
|
|
282
|
+
if (hasTheirs) await this.#deps.git.checkoutStage('theirs', resolution.path)
|
|
283
|
+
else await fs.rm(absolute, { force: true })
|
|
268
284
|
continue
|
|
269
285
|
}
|
|
270
|
-
if (resolution.forkTheirs) {
|
|
271
|
-
// 先取 theirs 工作树字节 → 写 fork 文件 →
|
|
286
|
+
if (resolution.forkTheirs && hasTheirs) {
|
|
287
|
+
// 先取 theirs 工作树字节 → 写 fork 文件 → 再恢复 ours 侧。
|
|
272
288
|
await this.#deps.git.checkoutStage('theirs', resolution.path)
|
|
273
|
-
const absolute = path.join(this.#deps.repoDir, ...resolution.path.split('/'))
|
|
274
289
|
const content = await fs.readFile(absolute)
|
|
275
290
|
const forkName = forkFileName(path.posix.basename(resolution.path), stamp, this.deviceShort)
|
|
276
291
|
await fs.writeFile(path.join(path.dirname(absolute), forkName), content)
|
|
277
|
-
|
|
292
|
+
// ours 缺失=本地已删除:保留删除,远端内容只以 fork 文件存续。
|
|
293
|
+
if (hasOurs) await this.#deps.git.checkoutStage('ours', resolution.path)
|
|
294
|
+
else await fs.rm(absolute, { force: true })
|
|
278
295
|
const forkRel = path.posix.join(path.posix.dirname(resolution.path), forkName)
|
|
279
296
|
forks.push(forkRel)
|
|
280
297
|
continue
|
|
281
298
|
}
|
|
282
|
-
|
|
299
|
+
// 远端已删除(theirs 缺失):保留本地版本,分歧照常计入 summary.diverged。
|
|
300
|
+
if (hasOurs) await this.#deps.git.checkoutStage('ours', resolution.path)
|
|
301
|
+
else await fs.rm(absolute, { force: true })
|
|
283
302
|
}
|
|
284
303
|
await this.#deps.git.addAll()
|
|
285
304
|
return { adopted: summary.adopted, appended: summary.appended, diverged: summary.diverged, forks }
|
package/lib/mirror.mjs
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { promises as fs } from 'node:fs'
|
|
12
12
|
import path from 'node:path'
|
|
13
|
+
import { createHash } from 'node:crypto'
|
|
13
14
|
import { FORK_NAME_RE, HOST_ARTIFACT_NAME_RE } from './constants.mjs'
|
|
14
15
|
|
|
15
16
|
/** 递归枚举 root 下全部常规文件(POSIX 相对路径;符号链接跳过并回报)。 */
|
|
@@ -56,6 +57,34 @@ async function writeIfDifferent(target, content) {
|
|
|
56
57
|
return true
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/** 源快照状态文件:本地、不进提交、不随仓库同步。 */
|
|
61
|
+
export const SOURCE_SNAPSHOT_FILE = path.join('.git', 'dsh-session-sync-mirror.json')
|
|
62
|
+
|
|
63
|
+
/** @param {string} repoDir */
|
|
64
|
+
async function readSourceSnapshot(repoDir) {
|
|
65
|
+
try {
|
|
66
|
+
const raw = await fs.readFile(path.join(repoDir, SOURCE_SNAPSHOT_FILE), 'utf8')
|
|
67
|
+
const parsed = JSON.parse(raw)
|
|
68
|
+
if (parsed === null || typeof parsed !== 'object' || !Array.isArray(parsed.sourcePaths)) return undefined
|
|
69
|
+
return new Set(parsed.sourcePaths.filter(rel => typeof rel === 'string'))
|
|
70
|
+
} catch {
|
|
71
|
+
return undefined
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** @param {string} repoDir @param {Set<string>} sourcePaths */
|
|
76
|
+
async function writeSourceSnapshot(repoDir, sourcePaths) {
|
|
77
|
+
const target = path.join(repoDir, SOURCE_SNAPSHOT_FILE)
|
|
78
|
+
const payload = Buffer.from(`${JSON.stringify({ version: 1, sourcePaths: [...sourcePaths].sort() })}\n`)
|
|
79
|
+
try {
|
|
80
|
+
const st = await fs.stat(path.dirname(target))
|
|
81
|
+
if (!st.isDirectory()) return
|
|
82
|
+
} catch {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
await writeIfDifferent(target, payload)
|
|
86
|
+
}
|
|
87
|
+
|
|
59
88
|
/**
|
|
60
89
|
* 把 sessionRoot 镜像进 <repoDir>/<mirrorDir>/…。
|
|
61
90
|
* 宿主私有会话产物(租约/迁移暂存,HOST_ARTIFACT_NAME_RE)既不复制、也不删除:
|
|
@@ -68,6 +97,7 @@ export async function mirrorSessionRoot(deps) {
|
|
|
68
97
|
const source = await listFiles(deps.sessionRoot)
|
|
69
98
|
const mirrorRoot = path.join(deps.repoDir, deps.mirrorDir)
|
|
70
99
|
const targets = new Set()
|
|
100
|
+
const previous = await readSourceSnapshot(deps.repoDir)
|
|
71
101
|
|
|
72
102
|
let mirrored = 0
|
|
73
103
|
let unchanged = 0
|
|
@@ -86,6 +116,7 @@ export async function mirrorSessionRoot(deps) {
|
|
|
86
116
|
|
|
87
117
|
// 删除:目标树中源已不存在、且非 fork 命名、非宿主私有产物的文件。
|
|
88
118
|
const deleted = []
|
|
119
|
+
const remotePreserved = []
|
|
89
120
|
const forkedPreserved = []
|
|
90
121
|
const hostArtifactsPreserved = []
|
|
91
122
|
const targetFiles = []
|
|
@@ -117,13 +148,102 @@ export async function mirrorSessionRoot(deps) {
|
|
|
117
148
|
hostArtifactsPreserved.push(rel)
|
|
118
149
|
continue
|
|
119
150
|
}
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
151
|
+
if (targets.has(rel)) continue
|
|
152
|
+
if (previous === undefined || !previous.has(rel)) {
|
|
153
|
+
// Never delete a file this device did not previously mirror from its own
|
|
154
|
+
// sessionRoot: it arrived via pull, or provenance is unknown.
|
|
155
|
+
remotePreserved.push(rel)
|
|
156
|
+
continue
|
|
123
157
|
}
|
|
158
|
+
await fs.unlink(absolute)
|
|
159
|
+
deleted.push(rel)
|
|
160
|
+
}
|
|
161
|
+
await writeSourceSnapshot(deps.repoDir, targets)
|
|
162
|
+
|
|
163
|
+
return { mirrored, unchanged, skippedLinks: source.skipped, deleted, remotePreserved, snapshotUnknown: previous === undefined, forkedPreserved, hostArtifactsSkipped, hostArtifactsPreserved }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** 恢复状态文件:本地、不进提交、不随仓库同步。 */
|
|
167
|
+
export const RESTORE_STATE_FILE = path.join('.git', 'dsh-session-sync-restored.json')
|
|
168
|
+
|
|
169
|
+
/** @param {Buffer|string} content */
|
|
170
|
+
function hashContent(content) {
|
|
171
|
+
return createHash('sha256').update(content).digest('hex')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @param {string} repoDir */
|
|
175
|
+
async function readRestoreState(repoDir) {
|
|
176
|
+
try {
|
|
177
|
+
const raw = await fs.readFile(path.join(repoDir, RESTORE_STATE_FILE), 'utf8')
|
|
178
|
+
const parsed = JSON.parse(raw)
|
|
179
|
+
if (parsed === null || typeof parsed !== 'object' || parsed.version !== 1 || parsed.files === null || typeof parsed.files !== 'object') return new Map()
|
|
180
|
+
return new Map(Object.entries(parsed.files).filter(([rel, hash]) => typeof rel === 'string' && typeof hash === 'string'))
|
|
181
|
+
} catch {
|
|
182
|
+
return new Map()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** @param {string} repoDir @param {Map<string,string>} files */
|
|
187
|
+
async function writeRestoreState(repoDir, files) {
|
|
188
|
+
const target = path.join(repoDir, RESTORE_STATE_FILE)
|
|
189
|
+
const payload = Buffer.from(`${JSON.stringify({ version: 1, files: Object.fromEntries([...files].sort(([a], [b]) => a.localeCompare(b))) })}
|
|
190
|
+
`)
|
|
191
|
+
try {
|
|
192
|
+
const st = await fs.stat(path.dirname(target))
|
|
193
|
+
if (!st.isDirectory()) return
|
|
194
|
+
} catch {
|
|
195
|
+
return
|
|
124
196
|
}
|
|
197
|
+
await writeIfDifferent(target, payload)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** @param {string} root */
|
|
201
|
+
async function mirrorRelSet(root) {
|
|
202
|
+
const set = new Set()
|
|
203
|
+
try {
|
|
204
|
+
const entries = await fs.readdir(root, { recursive: true, withFileTypes: true })
|
|
205
|
+
for (const entry of entries) {
|
|
206
|
+
if (!entry.isFile()) continue
|
|
207
|
+
const parent = entry.parentPath ?? entry.path ?? root
|
|
208
|
+
set.add(path.relative(root, path.join(parent, entry.name)).split(path.sep).join('/'))
|
|
209
|
+
}
|
|
210
|
+
} catch {}
|
|
211
|
+
return set
|
|
212
|
+
}
|
|
125
213
|
|
|
126
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Remove live-store copies that this plugin restored from a previous pull and
|
|
216
|
+
* that the remote has now deleted, but only while the live bytes still match
|
|
217
|
+
* the restored hash. A user-edited copy is kept (and will push normally).
|
|
218
|
+
* @param {{repoDir: string, mirrorRoot: string, sessionRoot: string}} deps
|
|
219
|
+
* @returns {Promise<{pruned: string[], keptEdited: string[]}>}
|
|
220
|
+
*/
|
|
221
|
+
export async function pruneRestoredSessions(deps) {
|
|
222
|
+
const state = await readRestoreState(deps.repoDir)
|
|
223
|
+
if (state.size === 0) return { pruned: [], keptEdited: [] }
|
|
224
|
+
const mirror = await mirrorRelSet(deps.mirrorRoot)
|
|
225
|
+
const pruned = []
|
|
226
|
+
const keptEdited = []
|
|
227
|
+
for (const [rel, expected] of [...state]) {
|
|
228
|
+
if (mirror.has(rel)) continue
|
|
229
|
+
const target = path.join(deps.sessionRoot, ...rel.split('/'))
|
|
230
|
+
try {
|
|
231
|
+
const st = await fs.lstat(target)
|
|
232
|
+
if (st.isSymbolicLink()) { state.delete(rel); continue }
|
|
233
|
+
const content = await fs.readFile(target)
|
|
234
|
+
if (hashContent(content) === expected) {
|
|
235
|
+
await fs.unlink(target)
|
|
236
|
+
pruned.push(rel)
|
|
237
|
+
} else {
|
|
238
|
+
keptEdited.push(rel)
|
|
239
|
+
}
|
|
240
|
+
} catch {
|
|
241
|
+
// already gone
|
|
242
|
+
}
|
|
243
|
+
state.delete(rel)
|
|
244
|
+
}
|
|
245
|
+
await writeRestoreState(deps.repoDir, state)
|
|
246
|
+
return { pruned, keptEdited }
|
|
127
247
|
}
|
|
128
248
|
|
|
129
249
|
/**
|
|
@@ -131,8 +251,8 @@ export async function mirrorSessionRoot(deps) {
|
|
|
131
251
|
* into the mirror; the next push then saw those files as "missing locally" and
|
|
132
252
|
* unlinked them. This writes new/changed regular files back, never deletes, never
|
|
133
253
|
* follows symlinks, and never writes fork files or host-private artifacts.
|
|
134
|
-
* @param {object} deps - {mirrorRoot, sessionRoot, forkNameRe?}.
|
|
135
|
-
* @returns {Promise<{restored: number, unchanged: number, skipped: number}>}
|
|
254
|
+
* @param {object} deps - {repoDir, mirrorRoot, sessionRoot, forkNameRe?}.
|
|
255
|
+
* @returns {Promise<{restored: number, unchanged: number, skipped: number, tracked: number}>}
|
|
136
256
|
*/
|
|
137
257
|
export async function restoreSessionRoot(deps) {
|
|
138
258
|
const forkRe = deps.forkNameRe ?? FORK_NAME_RE
|
|
@@ -145,6 +265,7 @@ export async function restoreSessionRoot(deps) {
|
|
|
145
265
|
let restored = 0
|
|
146
266
|
let unchanged = 0
|
|
147
267
|
let skipped = 0
|
|
268
|
+
const state = deps.repoDir === undefined ? new Map() : await readRestoreState(deps.repoDir)
|
|
148
269
|
for (const entry of entries) {
|
|
149
270
|
if (!entry.isFile()) { skipped += 1; continue }
|
|
150
271
|
const parent = entry.parentPath ?? entry.path ?? deps.mirrorRoot
|
|
@@ -153,15 +274,22 @@ export async function restoreSessionRoot(deps) {
|
|
|
153
274
|
const basename = path.posix.basename(rel)
|
|
154
275
|
if (forkRe.test(basename) || HOST_ARTIFACT_NAME_RE.test(basename)) { skipped += 1; continue }
|
|
155
276
|
const target = path.join(deps.sessionRoot, ...rel.split('/'))
|
|
277
|
+
let existed = false
|
|
156
278
|
try {
|
|
157
279
|
const st = await fs.lstat(target)
|
|
158
280
|
if (st.isSymbolicLink()) { skipped += 1; continue }
|
|
281
|
+
existed = true
|
|
159
282
|
} catch { /* target absent */ }
|
|
160
|
-
const
|
|
283
|
+
const content = await fs.readFile(absolute)
|
|
284
|
+
const wrote = await writeIfDifferent(target, content)
|
|
161
285
|
if (wrote) restored += 1
|
|
162
286
|
else unchanged += 1
|
|
287
|
+
// Track only copies this plugin created (target absent before) or already
|
|
288
|
+
// tracked. A pre-existing user file is never claimed by the sync plugin.
|
|
289
|
+
if (!existed || state.has(rel)) state.set(rel, hashContent(content))
|
|
163
290
|
}
|
|
164
|
-
|
|
291
|
+
if (deps.repoDir !== undefined) await writeRestoreState(deps.repoDir, state)
|
|
292
|
+
return { restored, unchanged, skipped, tracked: state.size }
|
|
165
293
|
}
|
|
166
294
|
|
|
167
295
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-sync",
|
|
3
3
|
"description": "Cross-device sync for DeepSeek Harness sessions: a dedicated git mirror of the session store, append-only three-way merge with keep-both + fork conflict resolution, /sync command, sync_pull/sync_push/sync_status tools, and configurable auto push/pull",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.28",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/PerryLink/dsh-session-sync.git"
|
|
@@ -114,22 +114,22 @@
|
|
|
114
114
|
"zod": "^4.4.3"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@deepseek-ai/dsh-attachment": "0.2.1-
|
|
117
|
+
"@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
|
|
118
118
|
"@deepseek-ai/cordis": "^4.0.5-alpha.1",
|
|
119
119
|
"@deepseek-ai/cordis-plugin-include": "^1.0.10-alpha.1",
|
|
120
120
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.6-alpha.1",
|
|
121
|
-
"@deepseek-ai/dsh-commands": "0.2.1-
|
|
122
|
-
"@deepseek-ai/dsh-llm": "0.2.1-
|
|
123
|
-
"@deepseek-ai/dsh-session": "0.2.1-
|
|
124
|
-
"@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.1-
|
|
125
|
-
"@deepseek-ai/dsh-storage": "0.2.1-
|
|
126
|
-
"@deepseek-ai/dsh-storage-domain": "0.2.1-
|
|
127
|
-
"@deepseek-ai/dsh-storage-json": "0.2.1-
|
|
128
|
-
"@deepseek-ai/dsh-subprocess": "0.2.1-
|
|
129
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.1-
|
|
130
|
-
"@deepseek-ai/dsh-tools": "0.2.1-
|
|
131
|
-
"@deepseek-ai/dsh-user-approval": "0.2.1-
|
|
132
|
-
"@deepseek-ai/dsh-user-questions": "0.2.1-
|
|
121
|
+
"@deepseek-ai/dsh-commands": "0.2.1-rc.2",
|
|
122
|
+
"@deepseek-ai/dsh-llm": "0.2.1-rc.2",
|
|
123
|
+
"@deepseek-ai/dsh-session": "0.2.1-rc.2",
|
|
124
|
+
"@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.1-rc.2",
|
|
125
|
+
"@deepseek-ai/dsh-storage": "0.2.1-rc.2",
|
|
126
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.1-rc.2",
|
|
127
|
+
"@deepseek-ai/dsh-storage-json": "0.2.1-rc.2",
|
|
128
|
+
"@deepseek-ai/dsh-subprocess": "0.2.1-rc.2",
|
|
129
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
|
|
130
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2",
|
|
131
|
+
"@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
|
|
132
|
+
"@deepseek-ai/dsh-user-questions": "0.2.1-rc.2",
|
|
133
133
|
"@deepseek-ai/schemastery": "^3.18.5-alpha.1",
|
|
134
134
|
"@types/node": "^22.19.0",
|
|
135
135
|
"oxlint": "0.18.1",
|