dsh-session-sync 0.1.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/ARCHITECTURE.md +86 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/README.es.md +181 -0
- package/README.hi.md +181 -0
- package/README.md +181 -0
- package/README.pt.md +181 -0
- package/README.zh.md +181 -0
- package/SECURITY.md +39 -0
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/cordis.patch.yml +41 -0
- package/index.mjs +775 -0
- package/lib/constants.mjs +109 -0
- package/lib/domain.mjs +29 -0
- package/lib/engine.mjs +289 -0
- package/lib/errors.mjs +99 -0
- package/lib/gate.mjs +152 -0
- package/lib/git.mjs +377 -0
- package/lib/merge.mjs +96 -0
- package/lib/mirror.mjs +120 -0
- package/lib/paths.mjs +107 -0
- package/lib/render.mjs +107 -0
- package/lib/sanitize.mjs +105 -0
- package/lib/status.mjs +69 -0
- package/package.json +144 -0
- package/types.d.ts +132 -0
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`dsh-session-sync` mirrors the DSH session store into a dedicated git worktree and syncs it to a user-provided remote, giving cross-device session continuity with no cloud service. Session files are treated as **opaque bytes**: the plugin never parses JSONL/zstd — the physical encoding belongs to the harness, and the plugin's only job is to move those bytes, merge append-only histories, and report state.
|
|
6
|
+
|
|
7
|
+
## Roles
|
|
8
|
+
|
|
9
|
+
- **Consumes public services only**: `sessions`, `commands`, `storageDomain`, `subprocess` (hard `inject`); `tools` (registered via `ctx.inject(['tools'], …)` when present); `userQuestions` / `approval` (optional `ctx.get`, fail closed when absent).
|
|
10
|
+
- **`lib/` is zero-DSH-dependency**: services are wired only at the boundary in `index.mjs`; `lib/` depends only on `node:` built-ins (the single sanctioned exception is `lib/domain.mjs`, which imports `zod` and `@deepseek-ai/dsh-storage-domain` because the domain record schema is a persistence-boundary validator).
|
|
11
|
+
|
|
12
|
+
## Module map
|
|
13
|
+
|
|
14
|
+
| Module | Responsibility |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `index.mjs` | The single host face: `Config` schema + `resolveConfig`, `makeRunGit`, tool factories, the `/sync` command handler, auto modes, `apply()` |
|
|
17
|
+
| `lib/constants.mjs` | Vocabulary + protocol constants (backends, confirm channels, merge kinds, error codes, defaults, bounds) — zero dependency |
|
|
18
|
+
| `lib/errors.mjs` | Structured domain errors (`SyncError` with stable `code` + `details`) |
|
|
19
|
+
| `lib/paths.mjs` | Path resolution, nesting checks, and fork-file naming — pure |
|
|
20
|
+
| `lib/sanitize.mjs` | Pure display/log redaction (remote-URL credentials, tokens, `key=value` secrets, path-containment display) |
|
|
21
|
+
| `lib/merge.mjs` | Append-only three-way merge classification — pure |
|
|
22
|
+
| `lib/mirror.mjs` | Byte mirror from the session store into the worktree (`node:fs`) |
|
|
23
|
+
| `lib/git.mjs` | Git command layer: verb whitelist + argument assertions, never force-push/reset/rebase/branch-switch |
|
|
24
|
+
| `lib/engine.mjs` | Sync orchestration: `push` (mirror → commit → push, reconcile-and-retry once on rejection), `pull` (commit → fetch → three-way merge), `status` |
|
|
25
|
+
| `lib/status.mjs` | Read-only status collection (no fetch, no writes) |
|
|
26
|
+
| `lib/render.mjs` | Result text rendering (pure, JSON-safe inputs) |
|
|
27
|
+
| `lib/gate.mjs` | Confirmation gate + session-event adaptive gate |
|
|
28
|
+
| `lib/domain.mjs` | The `session-sync` storage-domain spec (state table, singleton key) |
|
|
29
|
+
|
|
30
|
+
## Data flow
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
$DSH_HOME/sessions ──byte mirror──▶ <repoDir>/sessions ──git──▶ custom remote
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
1. **Mirror** copies each session file as opaque bytes into the worktree (symlinks refused, deletions only for files that vanished at the source and are not fork files).
|
|
37
|
+
2. **Commit** records the mirror as a git commit (plugin identity, never the user's git identity).
|
|
38
|
+
3. **Push/pull** move commits to/from the configured remote over `ctx.subprocess`-driven git.
|
|
39
|
+
|
|
40
|
+
## Conflict resolution — never silently overwrite
|
|
41
|
+
|
|
42
|
+
The three-way merge compares `base` (merge base), `ours` (local), and `theirs` (remote) per file:
|
|
43
|
+
|
|
44
|
+
| Verdict | Condition | Outcome |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `identical` | `ours == theirs` | keep ours |
|
|
47
|
+
| `ours-only` | `theirs == base` | keep ours |
|
|
48
|
+
| `theirs-only` | `ours == base` | adopt theirs (remote-only append) |
|
|
49
|
+
| `append-both` | both appended past base | keep ours + fork file for theirs |
|
|
50
|
+
| `diverged` | neither is a superset | keep ours + fork file for theirs |
|
|
51
|
+
|
|
52
|
+
Fork files are named `<basename>.remote-fork-<UTC timestamp>-<device8>`; mirror and cleanup **never delete or overwrite** files matching that pattern, so both lineages always survive. When a conflicting session is live and has no open turn, the plugin also forks the session at the harness level and injects a persistent `user/message` notice into the child.
|
|
53
|
+
|
|
54
|
+
## Confirmation gate
|
|
55
|
+
|
|
56
|
+
`pull`/`push` (command and tools) cross `confirmSync`. `confirmVia: auto` prefers `userQuestions` then `approval`; an explicit `userQuestions` or `approval` forces one channel. With no answerer the operation **fails closed**. Read-only surfaces (`status`/`diff`/`log`) never ask. The `approval` channel requires an open turn (tools run inside a turn; `/sync` runs between turns and is directed to mount `userQuestions`).
|
|
57
|
+
|
|
58
|
+
## Session events (adaptive gate)
|
|
59
|
+
|
|
60
|
+
`sync/push`, `sync/pull`, and `sync/conflict` are declared through `SessionEventMap` declaration merging in `types.d.ts`. At runtime the plugin appends one only when either (a) the host's `KNOWN_SESSION_EVENT_TYPES` already includes the type, or (b) the host `Session.append` supports the `ignorable` envelope (`probeIgnorableAppend`). On `0.1.0-rc.6` neither is true, so the gate stays closed and appends are skipped — sessions keep loading. Once a host records the types, appends turn on automatically; the gate is never removed by hand.
|
|
61
|
+
|
|
62
|
+
## Storage domain
|
|
63
|
+
|
|
64
|
+
Sync metadata (`deviceId`, `lastPullAt`, `lastPushAt`, `lastPushHead`, `lastError`) lives in the `session-sync` storage domain (`state` table, singleton key). The device id is a random UUID also written to `device.txt` in the sync repository for cross-device fork attribution.
|
|
65
|
+
|
|
66
|
+
## Auto modes — all reversible
|
|
67
|
+
|
|
68
|
+
Every automatic behavior is a Cordis effect, so stop/hot-reload removes it:
|
|
69
|
+
|
|
70
|
+
- `autoPullOnStart` — `ctx.effect` pulls once on mount.
|
|
71
|
+
- `autoPushOnTurnEnd` — `ctx.on('session/event')` pushes after `turn/end`.
|
|
72
|
+
- `pullIntervalMinutes` — `ctx.setInterval` periodic pull.
|
|
73
|
+
|
|
74
|
+
Auto runs are covered by the config grant and never re-confirm.
|
|
75
|
+
|
|
76
|
+
## Safety boundaries
|
|
77
|
+
|
|
78
|
+
- **Verb whitelist** in `lib/git.mjs`; `-f`/`--force`/`--force-with-lease`/`+refspec`, `reset`, `clean`, `rebase`, and branch-switch `checkout` are refused.
|
|
79
|
+
- **Path containment** before any join (`PATH_UNSAFE` fails loud).
|
|
80
|
+
- **Symlinks never followed** on either side of the mirror.
|
|
81
|
+
- **Sanitize before display/log** — remote-URL credentials, tokens, and `key=value` secrets are redacted before reaching the model or the log.
|
|
82
|
+
- **Bounded subprocesses** — git runs with `GIT_TERMINAL_PROMPT=0` and `GIT_OPTIONAL_LOCKS=0`, deadline- and signal-bounded, with a per-stream output cap.
|
|
83
|
+
|
|
84
|
+
## Backend vocabulary
|
|
85
|
+
|
|
86
|
+
`backend: git` is the only implemented backend. End-to-end-encryption backends (age/GPG-style) are reserved; configuring one fails loudly at load, and keys never enter the sync repository.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-08-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Cross-device session sync for DeepSeek Harness: a dedicated git mirror of the session store, `push`/`pull`/`status` with append-only keep-both + fork conflict resolution (never silently overwrites), the `/sync` command (`status`/`pull`/`push`/`diff`/`log`/`help`), and the `sync_pull`/`sync_push`/`sync_status` model tools.
|
|
13
|
+
- Configurable auto modes: pull on mount (`autoPullOnStart`), push after each closed turn (`autoPushOnTurnEnd`), and periodic pull (`pullIntervalMinutes`), all reversible Cordis effects.
|
|
14
|
+
- Confirmation gate for mutating operations (`confirmVia: auto`/`userQuestions`/`approval`, fail closed when no answerer); read-only surfaces never ask.
|
|
15
|
+
- `sync/push`, `sync/pull`, and `sync/conflict` session events behind an adaptive gate (append only when the host records the types or supports the `ignorable` envelope).
|
|
16
|
+
- Session-level conflict fork with a persistent `user/message` notice when a diverged session is live and has no open turn.
|
|
17
|
+
- `session-sync` storage-domain metadata (device id, last pull/push, last push head, last error).
|
|
18
|
+
- Schemastery configuration with fail-loud bounds; every tunable documented in `cordis.patch.yml` and the five-language READMEs.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 dsh-memento contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.es.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# dsh-session-sync
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
**Sincronización de sesiones entre dispositivos para DeepSeek Harness — un espejo git dedicado de tu almacén de sesiones.**
|
|
6
|
+
|
|
7
|
+
*Sincroniza tus sesiones entre dispositivos, conserva ambos lados ante cualquier conflicto, nunca pierdas un turno.*
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://github.com/topics/dsh-plugin)
|
|
11
|
+
[](#)
|
|
12
|
+
[](https://github.com/PerryLink/dsh-session-sync/actions)
|
|
13
|
+
[](https://github.com/PerryLink/dsh-session-sync/releases)
|
|
14
|
+
[](https://www.npmjs.com/package/dsh-session-sync)
|
|
15
|
+
[](https://www.npmjs.com/package/dsh-session-sync)
|
|
16
|
+
|
|
17
|
+
[English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Compatibilidad
|
|
24
|
+
|
|
25
|
+
| Superficie | Estado |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Harness | DeepSeek Harness `0.1.0-rc.6` |
|
|
28
|
+
| Node | `^22.19.0 \|\| >=24.0.0` |
|
|
29
|
+
| Plataformas | Cualquier lugar donde `git` y DSH se ejecuten (espejo basado en git; sin código específico de plataforma) |
|
|
30
|
+
| Modelo | Los modelos solo texto funcionan plenamente; no se requiere visión ni capacidad extra |
|
|
31
|
+
|
|
32
|
+
## Qué obtienes
|
|
33
|
+
|
|
34
|
+
`dsh-session-sync` refleja tu almacén de sesiones de DSH en un árbol de trabajo git dedicado y lo sincroniza con un remoto que **tú** controlas — sin servicio en la nube, sin almacenamiento de terceros:
|
|
35
|
+
|
|
36
|
+
- **Comando `/sync`** — `status` (rama, remoto saneado, delante/detrás, archivos sucios, forks), `diff`, `log`, `pull`, `push`, `help`.
|
|
37
|
+
- **Herramientas `sync_status` / `sync_pull` / `sync_push`** — la misma superficie para el modelo, dentro de un turno.
|
|
38
|
+
- **Resolución de conflictos append-only** — los registros de sesión son append-only; ante cualquier divergencia el plugin conserva **ambos** lados (la versión local se conserva, la remota se preserva como archivos fork) y nunca sobrescribe en silencio. Las sesiones divergentes también pueden bifurcarse a nivel de sesión.
|
|
39
|
+
- **Modos automáticos** — pull al iniciar, push tras cada turno cerrado y pull periódico, todos configurables y reversibles.
|
|
40
|
+
- **Escrituras con confirmación** — `pull`/`push` preguntan primero (mediante `userQuestions` o `approval`); las superficies de solo lectura nunca preguntan; sin respondedor la operación falla cerrada.
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
dispositivo A remoto (tu repositorio git) dispositivo B
|
|
44
|
+
$DSH_HOME/sessions ──espejo──▶ commit ──push──▶ [sessions] ──pull──▶ merge (conservar ambos + fork)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Inicio rápido
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
# 1. instala el bundle en tu perfil
|
|
51
|
+
dsh plugin --profile web add "github:PerryLink/dsh-session-sync#main"
|
|
52
|
+
|
|
53
|
+
# o desde npm (versiones publicadas)
|
|
54
|
+
dsh plugin --profile web add dsh-session-sync
|
|
55
|
+
|
|
56
|
+
# 2. apúntalo a un remoto git privado y verifica la fila
|
|
57
|
+
dsh --profile web --dump-config | grep -A2 'id: session-sync'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Luego configura el remoto en tu parche de perfil (un repositorio **privado** es la base) y sincroniza:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
- insert:
|
|
64
|
+
- id: session-sync
|
|
65
|
+
name: dsh-session-sync
|
|
66
|
+
config:
|
|
67
|
+
remote: git@github.com:you/your-dsh-sessions.git
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
> /sync status
|
|
72
|
+
> /sync pull
|
|
73
|
+
> /sync push
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Instalación y desinstalación
|
|
77
|
+
|
|
78
|
+
- **Canal git** (último `main`): `dsh plugin --profile web add "github:PerryLink/dsh-session-sync#main"` (equivalente a instalar desde `git+https://github.com/PerryLink/dsh-session-sync.git`). Sin paso de compilación — `index.mjs` y `lib/` son los artefactos publicados.
|
|
79
|
+
- **Canal npm** (versiones publicadas): `dsh plugin --profile web add dsh-session-sync`.
|
|
80
|
+
- **Canal tarball**: `pnpm pack` en este repositorio, luego `dsh plugin --profile web add ./dsh-session-sync-<version>.tgz`.
|
|
81
|
+
- **Desinstalar**: `dsh plugin --profile web remove dsh-session-sync` (o elimina la fila del parche de perfil).
|
|
82
|
+
|
|
83
|
+
## Configuración
|
|
84
|
+
|
|
85
|
+
Todos los ajustes son campos de `Config` de Schemastery (modificables desde cordis.yml). Una sobrescritura dirigida por id reemplaza toda la fila — repite cada clave que necesites. `cordis.patch.yml` documenta cada clave en línea.
|
|
86
|
+
|
|
87
|
+
| Clave | Valor predeterminado | Significado |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `enabled` | `true` | Interruptor maestro; `false` desregistra el comando, las herramientas, los oyentes y los modos automáticos |
|
|
90
|
+
| `backend` | `git` | Backend de sincronización; solo `git` está implementado (los backends cifrados están reservados y fallan alto) |
|
|
91
|
+
| `sessionRoot` | `''` | Raíz del almacén de sesiones; vacío = `$DSH_HOME/sessions` (si faltan ambos, falla la carga) |
|
|
92
|
+
| `repoDir` | `''` | Raíz del árbol de trabajo; vacío = `$DSH_HOME/dsh-session-sync/repo` |
|
|
93
|
+
| `remote` | `''` | Dirección remota (requerida antes de pull/push; status/diff funcionan sin ella) |
|
|
94
|
+
| `branch` | `main` | Nombre de la rama remota |
|
|
95
|
+
| `gitBin` | `git` | Ruta del ejecutable git |
|
|
96
|
+
| `autoPullOnStart` | `false` | Hace pull una vez al montar el plugin (la configuración es la concesión; sin reconfirmar) |
|
|
97
|
+
| `autoPushOnTurnEnd` | `false` | Hace push tras cada turno cerrado |
|
|
98
|
+
| `pullIntervalMinutes` | `0` | Pull periódico cada N minutos (`0` = apagado, máx. `10080`) |
|
|
99
|
+
| `confirmVia` | `auto` | Canal de confirmación: `auto` (primero userQuestions, luego approval), `userQuestions`, `approval` |
|
|
100
|
+
| `graceMs` | `10000` | Periodo de gracia para matar git (ms) |
|
|
101
|
+
| `commandTimeoutMs` | `120000` | Tiempo de espera por comando (ms) |
|
|
102
|
+
| `maxOutputBytes` | `262144` | Límite de salida recolectada por flujo (bytes) |
|
|
103
|
+
| `commitName` | `dsh-session-sync` | Nombre del autor del commit |
|
|
104
|
+
| `commitEmail` | `dsh-session-sync@localhost` | Correo del autor del commit |
|
|
105
|
+
| `registerCommand` | `true` | Registra el comando `/sync` |
|
|
106
|
+
| `registerTools` | `true` | Registra las herramientas `sync_*` cuando el servicio tools está presente |
|
|
107
|
+
|
|
108
|
+
Ejemplo de sobrescritura en tu parche de perfil:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
- insert:
|
|
112
|
+
- id: session-sync
|
|
113
|
+
name: dsh-session-sync
|
|
114
|
+
config:
|
|
115
|
+
remote: git@github.com:you/your-dsh-sessions.git
|
|
116
|
+
branch: main
|
|
117
|
+
autoPushOnTurnEnd: true
|
|
118
|
+
pullIntervalMinutes: 30
|
|
119
|
+
confirmVia: userQuestions
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Herramientas y superficies
|
|
123
|
+
|
|
124
|
+
| Superficie | Solo lectura | Requiere confirmación | Notas |
|
|
125
|
+
|---|---|---|---|
|
|
126
|
+
| `/sync status` | ✅ | — | Rama, remoto saneado, delante/detrás, archivos sucios, archivos fork, último pull/push |
|
|
127
|
+
| `/sync diff` | ✅ | — | Cambios sin commit + estadística `HEAD..remote` (solo lectura) |
|
|
128
|
+
| `/sync log` | ✅ | — | Últimos commits del repositorio de sincronización |
|
|
129
|
+
| `/sync pull` | | ✅ | Fetch + merge con semántica de conservar ambos; lo local se conserva, lo remoto se preserva como forks |
|
|
130
|
+
| `/sync push` | | ✅ | Espejo + commit + push; nunca fuerza push, reconcilia y reintenta una vez ante rechazo |
|
|
131
|
+
| `sync_status` | ✅ | — | Los mismos datos que `/sync status` para el modelo |
|
|
132
|
+
| `sync_pull` | | ✅ | Pull invocable por el modelo |
|
|
133
|
+
| `sync_push` | | ✅ | Push invocable por el modelo |
|
|
134
|
+
|
|
135
|
+
## Permisos y datos
|
|
136
|
+
|
|
137
|
+
- **Permisos**: las operaciones mutadoras cruzan la puerta de confirmación (`confirmVia`); el plugin nunca reimplementa ni elude los servicios `userQuestions`/`approval` del harness. Los modos automáticos están cubiertos por la concesión de configuración y nunca reconfirman.
|
|
138
|
+
- **Datos**: los metadatos de sincronización (id de dispositivo, último pull/push, última cabecera de push, último error) viven en el dominio de almacenamiento `session-sync`. Los archivos de sesión se copian como bytes opacos — el plugin nunca los analiza. El id de dispositivo también se escribe en `device.txt` en el repositorio de sincronización para la atribución de forks entre dispositivos.
|
|
139
|
+
- **Registro de sesión**: `sync/push`, `sync/pull` y `sync/conflict` están declarados en `types.d.ts`; se anexan solo cuando el host registra los tipos (ver Limitaciones conocidas). Todo lo escrito o mostrado se sanea.
|
|
140
|
+
|
|
141
|
+
## Límites de seguridad
|
|
142
|
+
|
|
143
|
+
- **Nunca sobrescribe en silencio.** El merge de tres vías append-only conserva ambos lados ante cualquier divergencia; los archivos fork nunca se eliminan y git nunca fuerza push, resetea, rebase ni cambia de rama.
|
|
144
|
+
- **Contención de rutas.** Los archivos se reflejan como bytes opacos con enlaces simbólicos rechazados y cada ruta unida se comprueba por contención (`PATH_UNSAFE` falla alto).
|
|
145
|
+
- **Salida saneada.** Las credenciales de URL remota, los tokens y los secretos `key=value` se redactan antes de llegar al modelo o al registro; la visualización de rutas rechaza todo lo que esté fuera de su raíz.
|
|
146
|
+
- **Sin almacenamiento de credenciales.** El plugin no almacena credenciales; las credenciales de git viven en tu helper de credenciales normal. El backend de cifrado de extremo a extremo reservado no está implementado y las claves nunca entran en el repositorio de sincronización.
|
|
147
|
+
- **Endurecimiento de git.** git se ejecuta con `GIT_TERMINAL_PROMPT=0` y `GIT_OPTIONAL_LOCKS=0`, acotado por plazo y señal, con un límite de salida por flujo.
|
|
148
|
+
- **Falla cerrada.** La falta de respondedor de confirmación, de remoto o una ruta insegura rechaza la operación alto.
|
|
149
|
+
|
|
150
|
+
## Limitaciones conocidas
|
|
151
|
+
|
|
152
|
+
- **Solo backend git.** Los backends de cifrado de extremo a extremo (estilo age/GPG) están reservados pero no implementados; configurar uno falla alto al cargar. Hasta entonces, los bytes de sesión se almacenan sin cifrar en **tu** remoto git — usa un repositorio privado.
|
|
153
|
+
- **Se requiere git.** El plugin necesita el ejecutable `git` y el servicio `subprocess`; sin ellos, las operaciones de sincronización fallan con un motivo claro (los perfiles siguen arrancando).
|
|
154
|
+
- **Eventos de sesión en `0.1.0-rc.6`.** El harness aún no registra los tipos `sync/*`, por lo que en rc.6 los anexos al registro de sesión se omiten (las sesiones siguen cargando); el plugin los habilita automáticamente una vez que un host registra los tipos o soporta el envoltorio `ignorable`.
|
|
155
|
+
- **`approval` entre turnos.** `/sync` se ejecuta entre turnos, donde el canal `approval` no tiene un turno abierto al que adjuntarse; usa `confirmVia: userQuestions` para la sincronización por comando, o impulsa la sincronización mediante las herramientas dentro de un turno.
|
|
156
|
+
|
|
157
|
+
## Desarrollo
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
pnpm install # node ^22.19 || >=24
|
|
161
|
+
pnpm run typecheck && pnpm run typecheck:ci # tsc --checkJs contra los peers rc.6 publicados
|
|
162
|
+
pnpm test # node --test (6 suites; las suites git se omiten sin git)
|
|
163
|
+
pnpm run verify:self-contained # las specs de dependencias resuelven desde el registro
|
|
164
|
+
pnpm run verify:artifacts # archivos publicados presentes + index.mjs importable
|
|
165
|
+
pnpm run check:readmes # consistencia de los cinco README
|
|
166
|
+
pnpm pack # el tarball publicado
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
No hay paso de compilación: ESM puro, `index.mjs` y `lib/` son los artefactos publicados.
|
|
170
|
+
|
|
171
|
+
## Topics
|
|
172
|
+
|
|
173
|
+
`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `session-sync`, `session`, `git`, `sync`, `cross-device`
|
|
174
|
+
|
|
175
|
+
## Contribuyentes
|
|
176
|
+
|
|
177
|
+
- [@PerryLink](https://github.com/PerryLink) — creador y mantenedor: motor de espejo git, merge append-only conservando ambos, comando `/sync` y herramientas `sync_*`, modos automáticos, saneadores y documentación en cinco idiomas.
|
|
178
|
+
|
|
179
|
+
## Licencia
|
|
180
|
+
|
|
181
|
+
[LICENSE](LICENSE) (Apache License 2.0) © 2026 dsh-session-sync contributors
|