dsh-session-sync 0.2.26 → 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/ARCHITECTURE.md +0 -0
- package/CHANGELOG.md +17 -0
- package/LICENSE +0 -0
- package/README-es.md +114 -50
- package/README-hi.md +115 -51
- package/README-pt.md +114 -50
- package/README-zh.md +108 -44
- package/README.md +115 -51
- package/SECURITY.md +0 -0
- package/THIRD_PARTY_NOTICES.md +0 -0
- package/cordis.patch.yml +0 -0
- package/index.mjs +0 -0
- package/lib/age.mjs +0 -0
- package/lib/backend.mjs +0 -0
- package/lib/constants.mjs +0 -0
- package/lib/domain.mjs +0 -0
- package/lib/encrypted.mjs +16 -7
- package/lib/engine.mjs +28 -9
- package/lib/errors.mjs +0 -0
- package/lib/gate.mjs +0 -0
- package/lib/git.mjs +0 -0
- package/lib/merge.mjs +0 -0
- package/lib/mirror.mjs +136 -8
- package/lib/paths.mjs +0 -0
- package/lib/render.mjs +0 -0
- package/lib/sanitize.mjs +30 -11
- package/lib/status.mjs +0 -0
- package/package.json +14 -14
- package/types.d.ts +0 -0
package/README.md
CHANGED
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
|
|
25
25
|
[English](README.md) · [简体中文](README-zh.md) · [Español](README-es.md) · [Português](README-pt.md) · [हिन्दी](README-hi.md)
|
|
26
26
|
|
|
27
|
+
```sh
|
|
28
|
+
dsh plugin --profile <name> add dsh-session-sync
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
27
32
|
</div>
|
|
28
33
|
|
|
29
34
|
---
|
|
@@ -31,11 +36,18 @@
|
|
|
31
36
|
**📖 Ecosystem knowledge base** — measured data, not marketing: [plugin development guide · plugin-selection data · maintenance criteria](https://perrylink.github.io/dsh-plugin-guide/).
|
|
32
37
|
|
|
33
38
|
<!-- star-cta -->
|
|
39
|
+
## Install & uninstall
|
|
40
|
+
|
|
41
|
+
- **git channel** (latest `main`): `dsh plugin --profile web add github:PerryLink/dsh-session-sync` (equivalent to installing from `git+https://github.com/PerryLink/dsh-session-sync.git`). No build step — `index.mjs` and `lib/` are the shipped artifacts.
|
|
42
|
+
- **npm channel** (published releases): `dsh plugin --profile web add dsh-session-sync`.
|
|
43
|
+
- **tarball channel**: `pnpm pack` in this repo, then `dsh plugin --profile web add ./dsh-session-sync-<version>.tgz`.
|
|
44
|
+
- **uninstall**: `dsh plugin --profile web remove dsh-session-sync` (or remove the row from the profile patch).
|
|
45
|
+
|
|
34
46
|
## ⭐ 如果它帮到了你
|
|
35
47
|
|
|
36
|
-
这个插件是 [DSH 插件家族](https://github.com/PerryLink)的一员(
|
|
48
|
+
这个插件是 [DSH 插件家族](https://github.com/PerryLink)的一员(95 个,全部 Apache-2.0)。如果你在用,**给个 star** —— 它不会解锁任何功能,但会让下一个人在搜索里更容易找到它。
|
|
37
49
|
|
|
38
|
-
*English:* part of a
|
|
50
|
+
*English:* part of a 95 plugin family for DeepSeek Harness. If it is useful, **a star helps the next person find it** — nothing is gated behind it.
|
|
39
51
|
|
|
40
52
|
|
|
41
53
|
## What is dsh-session-sync?
|
|
@@ -107,13 +119,6 @@ Then set the remote in your profile patch (a **private** repository is the basel
|
|
|
107
119
|
> /sync push
|
|
108
120
|
```
|
|
109
121
|
|
|
110
|
-
## Install & uninstall
|
|
111
|
-
|
|
112
|
-
- **git channel** (latest `main`): `dsh plugin --profile web add github:PerryLink/dsh-session-sync` (equivalent to installing from `git+https://github.com/PerryLink/dsh-session-sync.git`). No build step — `index.mjs` and `lib/` are the shipped artifacts.
|
|
113
|
-
- **npm channel** (published releases): `dsh plugin --profile web add dsh-session-sync`.
|
|
114
|
-
- **tarball channel**: `pnpm pack` in this repo, then `dsh plugin --profile web add ./dsh-session-sync-<version>.tgz`.
|
|
115
|
-
- **uninstall**: `dsh plugin --profile web remove dsh-session-sync` (or remove the row from the profile patch).
|
|
116
|
-
|
|
117
122
|
## Configuration
|
|
118
123
|
|
|
119
124
|
All tunables are Schemastery `Config` fields (changeable from cordis.yml). An id-targeted override replaces the whole row — restate every key you need. `cordis.patch.yml` documents each key inline.
|
|
@@ -177,7 +182,7 @@ Example override in your profile patch:
|
|
|
177
182
|
|
|
178
183
|
## Security boundaries
|
|
179
184
|
|
|
180
|
-
- **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.
|
|
181
186
|
- **Path containment.** Files are mirrored as opaque bytes with symlinks refused and every joined path containment-checked (`PATH_UNSAFE` fails loud).
|
|
182
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.
|
|
183
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.
|
|
@@ -235,55 +240,114 @@ There is no build step: pure ESM, `index.mjs` and `lib/` are the shipped artifac
|
|
|
235
240
|
|
|
236
241
|
## PerryLink DSH Plugin Family
|
|
237
242
|
|
|
238
|
-
This project is one of the **
|
|
243
|
+
This project is one of the **87 actively maintained** DeepSeek Harness plugins from [PerryLink](https://github.com/PerryLink). The family roster is **95** plugins in total — **5 frozen**, **3 retired** — and stays collapsed below so every README keeps a short first screen. Expand it to see every row, with the reason in the Status column.
|
|
244
|
+
|
|
245
|
+
<details>
|
|
246
|
+
<summary>Expand all 95 plugins</summary>
|
|
239
247
|
|
|
240
248
|
| Plugin | One-liner | Status |
|
|
241
249
|
|---|---|---|
|
|
242
|
-
| **[dsh-
|
|
243
|
-
| **[dsh-
|
|
244
|
-
| **[dsh-
|
|
250
|
+
| **[dsh-aqua-input-check](https://github.com/PerryLink/dsh-aqua-input-check)** | 水产养殖投入品记录核对(按投入品用量、休药期与起捕间隔核对记录自洽,仅提示差异,不作出定性结论) | |
|
|
251
|
+
| **[dsh-archive-check](https://github.com/PerryLink/dsh-archive-check)** | 档案归档完整性与保管期限核对(依据《档案法》及配套规定,仅提示差异,不作出定性结论) | |
|
|
252
|
+
| **[dsh-auto-review](https://github.com/PerryLink/dsh-auto-review)** | Second-model auto-review on the approval chain, fail-closed by default | |
|
|
253
|
+
| **[dsh-autotier](https://github.com/PerryLink/dsh-autotier)** | Automatic strong/cheap model-tier routing with deterministic risk guards and a `/tier` command | |
|
|
254
|
+
| **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | Durable background child agents with a Web UI sidebar, messaging and interrupt | 🚫 RETIRED — see the repo README |
|
|
255
|
+
| **[dsh-bid-ca-precheck](https://github.com/PerryLink/dsh-bid-ca-precheck)** | 投标文件符合性预检(按招标文件逐条核对响应情况,仅提示差异,不作出定性结论) | |
|
|
256
|
+
| **[dsh-bid-qual-check](https://github.com/PerryLink/dsh-bid-qual-check)** | 投标人资格条件核对(按资格条件与证明材料核对逐条响应,仅提示差异,不作出定性结论) | |
|
|
245
257
|
| **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | Cost governance for DeepSeek Harness: budgets, carbon, and latency in one panel. | 🧊 FROZEN — see the repo README |
|
|
246
|
-
| **[dsh-
|
|
247
|
-
| **[dsh-
|
|
248
|
-
| **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | Claude Code /rewind-equivalent: snapshots, session forks, one-shot restore | |
|
|
258
|
+
| **[dsh-cert-mcp](https://github.com/PerryLink/dsh-cert-mcp)** | Read-only MCP server exposing the certification registry: grades, snapshots and five-dimension evidence | |
|
|
259
|
+
| **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | Claude Code /rewind-equivalent: snapshots, session forks, one-shot restore | |
|
|
249
260
|
| **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | Migrate Claude Code sessions, memory, skills and CLAUDE.md into DSH | 🧊 FROZEN — see the repo README |
|
|
250
|
-
| **[dsh-click](https://github.com/PerryLink/dsh-click)** | Cross-platform native desktop control for DeepSeek Harness — Windows first. |
|
|
251
|
-
| **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | Terminal-style input history for the web composer: arrows, Ctrl+R search |
|
|
252
|
-
| **[dsh-
|
|
261
|
+
| **[dsh-click](https://github.com/PerryLink/dsh-click)** | Cross-platform native desktop control for DeepSeek Harness — Windows first. | |
|
|
262
|
+
| **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | Terminal-style input history for the web composer: arrows, Ctrl+R search | |
|
|
263
|
+
| **[dsh-contract-stance](https://github.com/PerryLink/dsh-contract-stance)** | 合同条款立场台账核对(按立场、风险等级与退让底线核对台账自洽,仅提示差异,不作出定性结论) | |
|
|
264
|
+
| **[dsh-customs-doc-check](https://github.com/PerryLink/dsh-customs-doc-check)** | 报关单证一致性核对(按公开的报关单填制规范核对单证间字段一致性,仅提示差异,不作出定性结论) | |
|
|
265
|
+
| **[dsh-data-quality](https://github.com/PerryLink/dsh-data-quality)** | Dataset quality checks and citation cross-checks (the optional numeric bridge consumed here) | |
|
|
253
266
|
| **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | Prompt-injection, jailbreak, and secret-leak defense for DeepSeek Harness. | 🧊 FROZEN — see the repo README |
|
|
254
|
-
| **[dsh-
|
|
267
|
+
| **[dsh-demurrage-ledger](https://github.com/PerryLink/dsh-demurrage-ledger)** | 滞箱费台账核对(按免箱期与费率核对超期天数与金额的自洽性,仅提示差异,不作出定性结论) | |
|
|
268
|
+
| **[dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck)** | Engineering-discipline guard: requirements grill, test gates, adversary review | |
|
|
255
269
|
| **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | Unified static-image generation routing for DeepSeek Harness. | 🧊 FROZEN — see the repo README |
|
|
256
|
-
| **[dsh-
|
|
257
|
-
| **[dsh-
|
|
258
|
-
| **[dsh-
|
|
259
|
-
| **[dsh-
|
|
260
|
-
| **[dsh-
|
|
261
|
-
| **[dsh-
|
|
262
|
-
| **[dsh-
|
|
263
|
-
| **[dsh-
|
|
264
|
-
| **[dsh-
|
|
265
|
-
| **[dsh-
|
|
266
|
-
| **[dsh-
|
|
267
|
-
| **[dsh-
|
|
268
|
-
| **[dsh-
|
|
269
|
-
| **[dsh-
|
|
270
|
-
| **[dsh-
|
|
271
|
-
| **[dsh-
|
|
272
|
-
| **[dsh-
|
|
273
|
-
| **[dsh-
|
|
274
|
-
| **[dsh-
|
|
275
|
-
| **[dsh-
|
|
270
|
+
| **[dsh-drill-script-check](https://github.com/PerryLink/dsh-drill-script-check)** | 应急演练脚本核对(按阶段、响应分级、指挥与资源要素核对脚本齐备,仅提示差异,不作出定性结论) | |
|
|
271
|
+
| **[dsh-eia-guide-check](https://github.com/PerryLink/dsh-eia-guide-check)** | 环评导则适用性核对(按要素、导则名称与执行标准核对台账自洽,仅提示差异,不作出定性结论) | |
|
|
272
|
+
| **[dsh-emergency-plan](https://github.com/PerryLink/dsh-emergency-plan)** | 应急预案要素齐备性与条款级页码定位(依据 GB/T 29639-2020 等公开文件,仅提示差异,不作出定性结论) | |
|
|
273
|
+
| **[dsh-essay-rubric-check](https://github.com/PerryLink/dsh-essay-rubric-check)** | 作文量表评分核对(按评分项、原文定位与分值算术核对评分自洽,仅提示差异,不作出定性结论) | |
|
|
274
|
+
| **[dsh-evidence-check](https://github.com/PerryLink/dsh-evidence-check)** | 证据清单齐备性核对(按待证事实与证据要素核对清单自洽,仅提示差异,不作出定性结论) | |
|
|
275
|
+
| **[dsh-export-ctl-check](https://github.com/PerryLink/dsh-export-ctl-check)** | 出口管制物项核对(按管制清单、最终用途与许可证核对台账齐备,仅提示差异,不作出定性结论) | |
|
|
276
|
+
| **[dsh-fast](https://github.com/PerryLink/dsh-fast)** | Read-only performance diagnostics for DeepSeek Harness. | |
|
|
277
|
+
| **[dsh-fmea-table-check](https://github.com/PerryLink/dsh-fmea-table-check)** | FMEA 分析表要素齐备性与风险顺序数一致性核对(按公开的 FMEA 方法标准核对表内自洽,仅提示差异,不作出定性结论) | |
|
|
278
|
+
| **[dsh-forecast-penalty](https://github.com/PerryLink/dsh-forecast-penalty)** | 预测准确率考核核对(按准确率、门槛与考核单价核对考核费用的算术自洽,仅提示差异,不作出定性结论) | |
|
|
279
|
+
| **[dsh-fund-research](https://github.com/PerryLink/dsh-fund-research)** | Deterministic research reports for Chinese public mutual funds | |
|
|
280
|
+
| **[dsh-github](https://github.com/PerryLink/dsh-github)** | GitHub PR/issues integration for DSH, every write gated by approval | |
|
|
281
|
+
| **[dsh-gongwen-flow-check](https://github.com/PerryLink/dsh-gongwen-flow-check)** | 公文流转与办理时限核对(按公开的公文处理规范核对环节完整性与时限,仅提示差异,不作出定性结论) | |
|
|
282
|
+
| **[dsh-gongwen-word-check](https://github.com/PerryLink/dsh-gongwen-word-check)** | 公文格式要素核对(按公开的党政机关公文格式标准核对版头与主体要素,仅提示差异,不作出定性结论) | |
|
|
283
|
+
| **[dsh-guard-plan-qc](https://github.com/PerryLink/dsh-guard-plan-qc)** | 劳动保护与安全防护用品配置表核对(按公开的配备标准核对品名规格与配置数量,仅提示差异,不作出定性结论) | |
|
|
284
|
+
| **[dsh-hazchem-check](https://github.com/PerryLink/dsh-hazchem-check)** | 危险化学品临界量与重大危险源辨识核对(按储存量与临界量核对台账自洽,仅提示差异,不作出定性结论) | |
|
|
285
|
+
| **[dsh-hazplan-check](https://github.com/PerryLink/dsh-hazplan-check)** | HAZOP 分析表要素齐备性与偏差推导一致性核对(依据公开的危险与可操作性分析标准,仅提示差异,不作出定性结论) | |
|
|
286
|
+
| **[dsh-hidden-risk-map](https://github.com/PerryLink/dsh-hidden-risk-map)** | 安全隐患台账→《工贸企业重大事故隐患判定标准》(应急管理部令第10号)条款映射提示(仅提示差异,不作出定性结论) | |
|
|
287
|
+
| **[dsh-hs-classify](https://github.com/PerryLink/dsh-hs-classify)** | 商品归类层级一致性核对(按章、品目、子目与商品编号的层级关系核对自洽,仅提示差异,不作出定性结论) | |
|
|
288
|
+
| **[dsh-icd-rule-check](https://github.com/PerryLink/dsh-icd-rule-check)** | ICD 合并编码与星剑号配对提示(依据 GB/T 14396-2016 与公开的 ICD 使用说明,仅提示差异,不作出定性结论) | |
|
|
289
|
+
| **[dsh-industry-research](https://github.com/PerryLink/dsh-industry-research)** | Industry research orchestration that seals its deliverables through this plugin's `ctx.researchReport.assemble` | |
|
|
290
|
+
| **[dsh-lawcite-adapter](https://github.com/PerryLink/dsh-lawcite-adapter)** | 法条引用与文书要素核对(按名称、条号、原文与效力状态核对引用可核验性,仅提示差异,不作出定性结论) | |
|
|
291
|
+
| **[dsh-laya](https://github.com/PerryLink/dsh-laya)** | Laya typed decisions (`noul`/`choice`/`score`) as a first-class Cordis service and model-visible tools | |
|
|
292
|
+
| **[dsh-lc-doc-check](https://github.com/PerryLink/dsh-lc-doc-check)** | 信用证单据条款核对(按单据种类、份数、期限与不符点核对交单自洽,仅提示差异,不作出定性结论) | |
|
|
293
|
+
| **[dsh-learning-gap-check](https://github.com/PerryLink/dsh-learning-gap-check)** | 能力差距与培养计划核对(按能力等级差、培养措施与完成期限核对台账闭环,仅提示差异,不作出定性结论) | |
|
|
294
|
+
| **[dsh-library](https://github.com/PerryLink/dsh-library)** | Local document knowledge base for DeepSeek Harness. | |
|
|
295
|
+
| **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | Local-model (Ollama) integration for DeepSeek Harness. | |
|
|
296
|
+
| **[dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions)** | LSP diagnostics, formatting, completion, code actions and rename over language servers | |
|
|
297
|
+
| **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | PII masking middleware: anonymize at the model boundary, restore at the display layer | |
|
|
298
|
+
| **[dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel)** | Read-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors | |
|
|
299
|
+
| **[dsh-medrec-qc](https://github.com/PerryLink/dsh-medrec-qc)** | 病案首页形式质控与逻辑矛盾提示(依据国卫办医发〔2016〕24号等公开文件,仅提示差异,不作出定性结论) | |
|
|
300
|
+
| **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | Approval-gated cross-session memory: ctx.memory seam + SQLite + memory tool | |
|
|
301
|
+
| **[dsh-nsfc-form-check](https://github.com/PerryLink/dsh-nsfc-form-check)** | 国家自然科学基金申请书形式审查与匿名化提示(依据《国家自然科学基金条例》与申请人导入的当年指南,仅提示差异,不作出定性结论) | |
|
|
302
|
+
| **[dsh-nurse-record-check](https://github.com/PerryLink/dsh-nurse-record-check)** | 护理记录时限、签名与评估表完整性校验(依据《病历书写基本规范》等公开文件,仅提示差异,不作出定性结论) | |
|
|
303
|
+
| **[dsh-observe](https://github.com/PerryLink/dsh-observe)** | OpenTelemetry and Langfuse observability exporter for DeepSeek Harness. | |
|
|
304
|
+
| **[dsh-origin-rvc-check](https://github.com/PerryLink/dsh-origin-rvc-check)** | 原产地区域价值成分核对(按 RVC 定义式与门槛核对原产地判定自洽,仅提示差异,不作出定性结论) | |
|
|
305
|
+
| **[dsh-ota-review-check](https://github.com/PerryLink/dsh-ota-review-check)** | 在线点评回复台账核对(按回复时限、问题分类与整改状态核对台账闭环,仅提示差异,不作出定性结论) | |
|
|
306
|
+
| **[dsh-output-styles](https://github.com/PerryLink/dsh-output-styles)** | Claude Code outputStyles-equivalent runtime style switching | |
|
|
307
|
+
| **[dsh-paper-doc-adapter](https://github.com/PerryLink/dsh-paper-doc-adapter)** | 试卷解析结构核对(按题型、答案、分值与 yotta 标识核对试卷结构自洽,仅提示差异,不作出定性结论) | |
|
|
308
|
+
| **[dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules)** | Claude Code-style declarative allow/deny/ask permission rules with audit | |
|
|
309
|
+
| **[dsh-permit-report-check](https://github.com/PerryLink/dsh-permit-report-check)** | 行政许可办理核对(按申请材料、法定时限与决定记录核对台账闭环,仅提示差异,不作出定性结论) | |
|
|
310
|
+
| **[dsh-pipeline-check](https://github.com/PerryLink/dsh-pipeline-check)** | 项目全流程文件链条核对(按环节先后与金额口径核对链条自洽,仅提示差异,不作出定性结论) | |
|
|
311
|
+
| **[dsh-pleading-draft](https://github.com/PerryLink/dsh-pleading-draft)** | 起诉状要素齐备性核对(按诉请、事实、证据、法条四要素核对文书齐备,仅提示差异,不作出定性结论) | |
|
|
312
|
+
| **[dsh-plugin-doctor](https://github.com/PerryLink/dsh-plugin-doctor)** | Zero-dependency static + sandbox smoke detector for DSH plugins | |
|
|
313
|
+
| **[dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide)** | Plugin-development knowledge base as an on-demand agent skill | |
|
|
314
|
+
| **[dsh-plugin-kit](https://github.com/PerryLink/dsh-plugin-kit)** | Shared zero-runtime-dependency toolkit for the PerryLink DSH plugins | |
|
|
315
|
+
| **[dsh-plugin-upgrade](https://github.com/PerryLink/dsh-plugin-upgrade)** | One-package, one-corridor-index plugin upgrade skill: routes a repository to the matching closed corridor card | |
|
|
316
|
+
| **[dsh-policy-brief-draft](https://github.com/PerryLink/dsh-policy-brief-draft)** | 政策专报要素核对(按观点、依据、出处与建议核对专报齐备,仅提示差异,不作出定性结论) | |
|
|
317
|
+
| **[dsh-power-loss-split](https://github.com/PerryLink/dsh-power-loss-split)** | 线损电量拆分与考核表核对(依据公开的线损计算口径,仅提示差异,不作出定性结论) | |
|
|
318
|
+
| **[dsh-power-ticket-check](https://github.com/PerryLink/dsh-power-ticket-check)** | 电力工作票要素齐备性与签发许可顺序核对(依据现行电力安全工作规程,仅提示差异,不作出定性结论) | |
|
|
319
|
+
| **[dsh-ppap-check](https://github.com/PerryLink/dsh-ppap-check)** | PPAP 提交要素齐备性核对(按公开的 PPAP 手册与提交等级核对要素齐备与版本填写,仅提示差异,不作出定性结论) | |
|
|
320
|
+
| **[dsh-protest-deadline](https://github.com/PerryLink/dsh-protest-deadline)** | 质疑与投诉期限核对(按公开的政府采购质疑投诉规定核对期限与台账自洽,仅提示差异,不作出定性结论) | |
|
|
321
|
+
| **[dsh-railway-window](https://github.com/PerryLink/dsh-railway-window)** | 铁路施工天窗台账核对(按时间窗、时长算术与命令号核对台账自洽,仅提示差异,不作出定性结论) | |
|
|
276
322
|
| **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | Multi-channel approval/question bridge: WeChat/Telegram/Feishu, session console | 🧊 FROZEN — see the repo README |
|
|
277
|
-
| **[dsh-
|
|
278
|
-
| **[dsh-
|
|
279
|
-
| **[dsh-
|
|
280
|
-
| **[dsh-
|
|
281
|
-
| **[dsh-
|
|
282
|
-
| **[dsh-
|
|
283
|
-
| **[dsh-
|
|
284
|
-
| **[dsh-
|
|
285
|
-
| **[dsh-
|
|
286
|
-
| **[dsh-
|
|
323
|
+
| **[dsh-repair-order-qc](https://github.com/PerryLink/dsh-repair-order-qc)** | 维修工单结算核对(按项目金额、配件工时合计与结算总额核对算术自洽,仅提示差异,不作出定性结论) | |
|
|
324
|
+
| **[dsh-research-report](https://github.com/PerryLink/dsh-research-report)** | Verifiable research-report engine: content-addressed evidence ledger and sealed versions | |
|
|
325
|
+
| **[dsh-review-reply-check](https://github.com/PerryLink/dsh-review-reply-check)** | 审稿意见逐条回应覆盖核对(按意见与回应一一对应核对覆盖完整性,仅提示差异,不作出定性结论) | |
|
|
326
|
+
| **[dsh-rulefile-check](https://github.com/PerryLink/dsh-rulefile-check)** | 规则库文件自检核对(按条款引用纪律与效力上限核对规则库自身合规,仅提示差异,不作出定性结论) | |
|
|
327
|
+
| **[dsh-safety-brief-check](https://github.com/PerryLink/dsh-safety-brief-check)** | 安全技术交底记录要素齐备性与签字闭环核对(依据公开的安全生产法规与检查标准,仅提示差异,不作出定性结论) | |
|
|
328
|
+
| **[dsh-score](https://github.com/PerryLink/dsh-score)** | Multi-dimensional quality scoring for DeepSeek Harness plugins. | |
|
|
329
|
+
| **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | Pin sessions in the Web sidebar with durable ordering | 🚫 RETIRED — see the repo README |
|
|
330
|
+
| **[dsh-session-sync](https://github.com/PerryLink/dsh-session-sync)** | Cross-device session sync for DeepSeek Harness — a dedicated git mirror of your session store. | |
|
|
331
|
+
| **[dsh-site-log-check](https://github.com/PerryLink/dsh-site-log-check)** | 监理日志跨日连续性与旁站覆盖提示(依据 GB/T 50319-2013 等公开文件,仅提示差异,不作出定性结论) | |
|
|
332
|
+
| **[dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security)** | Security-audit skill pack: secret scan, dependency and supply-chain review | |
|
|
333
|
+
| **[dsh-soe-decision-check](https://github.com/PerryLink/dsh-soe-decision-check)** | 三重一大决策台账核对(按前置研究、会议审议与决议记录核对程序留痕,仅提示差异,不作出定性结论) | |
|
|
334
|
+
| **[dsh-soilwater-check](https://github.com/PerryLink/dsh-soilwater-check)** | 土壤与地下水监测台账核对(按点位、监测项目、限值与超标判定核对台账自洽,仅提示差异,不作出定性结论) | |
|
|
335
|
+
| **[dsh-sop-sync-check](https://github.com/PerryLink/dsh-sop-sync-check)** | 作业规程与 FMEA/控制计划一致性核对(按编号与版本核对三份文件是否同步,仅提示差异,不作出定性结论) | |
|
|
336
|
+
| **[dsh-spc-gbt-adapter](https://github.com/PerryLink/dsh-spc-gbt-adapter)** | 控制图常数与过程能力指数核对(按 GB/T 4091 的常规控制图常数表核对控制限与 Cp/Cpk 的自洽性,仅提示差异,不作出定性结论) | |
|
|
337
|
+
| **[dsh-talk](https://github.com/PerryLink/dsh-talk)** | Voice-first session loop for DeepSeek Harness: talk to it, hear it answer. | |
|
|
338
|
+
| **[dsh-team-rooms](https://github.com/PerryLink/dsh-team-rooms)** | Cross-session team rooms: shared message bus, task board and timeline | 🚫 RETIRED — see the repo README |
|
|
339
|
+
| **[dsh-tender-extract](https://github.com/PerryLink/dsh-tender-extract)** | 招标文件条款摘录核对(按出处与原文逐字核对摘录完整性,仅提示差异,不作出定性结论) | |
|
|
340
|
+
| **[dsh-tender-matrix](https://github.com/PerryLink/dsh-tender-matrix)** | 评标因素评分矩阵核对(按分值上限与合计核对矩阵自洽,仅提示差异,不作出定性结论) | |
|
|
341
|
+
| **[dsh-test-drive](https://github.com/PerryLink/dsh-test-drive)** | Isolated install-and-smoke test drives for DeepSeek Harness plugins. | |
|
|
342
|
+
| **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** | TickTick/Dida365 task bridge: session-header panel + 11 tools | |
|
|
343
|
+
| **[dsh-translate](https://github.com/PerryLink/dsh-translate)** | Vendor parameter translation and deterministic JSON repair for DeepSeek Harness. | |
|
|
344
|
+
| **[dsh-warranty-calc](https://github.com/PerryLink/dsh-warranty-calc)** | 质保期与索赔金额核对(按质保期月数与里程、索赔金额算式核对自洽,仅提示差异,不作出定性结论) | |
|
|
345
|
+
|
|
346
|
+
</details>
|
|
347
|
+
|
|
348
|
+
</details>
|
|
349
|
+
|
|
350
|
+
</details>
|
|
287
351
|
|
|
288
352
|
### Install from the DSH Desktop Market
|
|
289
353
|
|
package/SECURITY.md
CHANGED
|
File without changes
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
File without changes
|
package/cordis.patch.yml
CHANGED
|
File without changes
|
package/index.mjs
CHANGED
|
File without changes
|
package/lib/age.mjs
CHANGED
|
File without changes
|
package/lib/backend.mjs
CHANGED
|
File without changes
|
package/lib/constants.mjs
CHANGED
|
File without changes
|
package/lib/domain.mjs
CHANGED
|
File without changes
|
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/errors.mjs
CHANGED
|
File without changes
|
package/lib/gate.mjs
CHANGED
|
File without changes
|
package/lib/git.mjs
CHANGED
|
File without changes
|
package/lib/merge.mjs
CHANGED
|
File without changes
|
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/lib/paths.mjs
CHANGED
|
File without changes
|
package/lib/render.mjs
CHANGED
|
File without changes
|