dsh-session-sync 0.2.33 → 0.3.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 CHANGED
@@ -19,7 +19,10 @@
19
19
  | `lib/paths.mjs` | Path resolution, nesting checks, and fork-file naming — pure |
20
20
  | `lib/sanitize.mjs` | Pure display/log redaction (remote-URL credentials, tokens, `key=value` secrets, path-containment display) |
21
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`) |
22
+ | `lib/mirror.mjs` | Byte mirror from the session store into the worktree, restore back into the live store, and deletion protection (`node:fs`). Projection-aware: projected local copies are skipped as sources and reattached to the mirror's original header frame; `followSessionSymlinks` opts into contained links only |
23
+ | `lib/cwdmap.mjs` | Restore-time cwd matching/projection — pure (`cwdMap` longest-prefix + segment boundary, host-compatible `projectKey`, `--unmapped--` fallback) |
24
+ | `lib/sessionlog.mjs` | Session-log first frame read/rewrite (`node:zlib`): the header is its own zstd frame, so a projection replaces only that frame |
25
+ | `lib/projection.mjs` | Local projection state (`.git/dsh-session-sync-projection.json`): canonical↔projected path pairs, original cwd and header frame; plans restore placement and reconstructs canonical bytes on push |
23
26
  | `lib/git.mjs` | Git command layer: verb whitelist + argument assertions, never force-push/reset/rebase/branch-switch |
24
27
  | `lib/backend.mjs` | Transport backend seam contract + pure `selectEncryptionMode` (backend/mode/warnings selection) |
25
28
  | `lib/age.mjs` | age binary probe (`detectAge`) + file-based `ageEncrypt`/`ageDecrypt` (optional external binary, graceful degrade) |
@@ -36,9 +39,10 @@
36
39
  $DSH_HOME/sessions ──byte mirror──▶ <repoDir>/sessions ──git──▶ custom remote
37
40
  ```
38
41
 
39
- 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 neither fork files nor host-private artifacts). Host-private artifacts (`session.lock`, the harness session lease, and `session.migration.*.tmp` staging files) are runtime state, not syncable content: the mirror neither copies them in nor deletes them from the worktree.
42
+ 1. **Mirror** copies each session file as opaque bytes into the worktree (symlinks refused by default, deletions only for files that vanished at the source and are neither fork files nor host-private artifacts). Host-private artifacts (`session.lock`, the harness session lease, and `session.migration.*.tmp` staging files) are runtime state, not syncable content: the mirror neither copies them in nor deletes them from the worktree. With `followSessionSymlinks: true` only links whose `realpath` stays inside `sessionRoot` are read (still never written through), and every skipped link is reported.
40
43
  2. **Commit** records the mirror as a git commit (plugin identity, never the user's git identity).
41
44
  3. **Push/pull** move commits to/from the configured remote over `ctx.subprocess`-driven git.
45
+ 4. **Restore projection (`cwdMap`)** — a cross-OS session's `header.cwd` is not natively absolute on the receiving host, so neither the workspace index nor the JSONL backend can read it. On restore, `lib/cwdmap.mjs` maps the origin prefix to a local path (longest prefix, segment boundary), `lib/projection.mjs` rewrites the **first frame of the local copy only**, and the file lands at `<projectKey(mapped cwd)>/<sessionId>/<file>` — the same formula the host validates. The mirror keeps the origin device's bytes; on push the original header frame is reattached, so the remote sees only the locally appended frames (byte-identical append-only merge, no fork churn). Without a mapping entry a cross-platform cwd goes read-only to `<sessionRoot>/--unmapped--` (visible, `cwdUnmapped` in status, never a push source) and its mapped directory is created so the host can group it.
42
46
 
43
47
  ## Conflict resolution — never silently overwrite
44
48
 
@@ -80,12 +84,15 @@ Auto runs are covered by the config grant and never re-confirm.
80
84
 
81
85
  - **Verb whitelist** in `lib/git.mjs`; `-f`/`--force`/`--force-with-lease`/`+refspec`, `reset`, `clean`, `rebase`, and branch-switch `checkout` are refused.
82
86
  - **Path containment** before any join (`PATH_UNSAFE` fails loud).
83
- - **Symlinks never followed** on either side of the mirror.
87
+ - **Symlinks never followed by default** on either side of the mirror. `followSessionSymlinks: true` (opt-in) reads only links whose `realpath` stays inside `sessionRoot`; writes still refuse link targets and escape paths.
88
+ - **Restore projection never rewrites the synced bytes.** Only the local copy's first frame changes; the mirror always receives the origin header frame plus the locally appended frames, so cross-platform mapping cannot create meaningless divergence.
84
89
  - **Sanitize before display/log** — remote-URL credentials, tokens, and `key=value` secrets are redacted before reaching the model or the log.
85
90
  - **Bounded subprocesses** — git runs with `GIT_TERMINAL_PROMPT=0` and `GIT_OPTIONAL_LOCKS=0`, deadline- and signal-bounded, with a per-stream output cap.
86
91
 
87
92
  ## Upstream asks (recorded, not implemented)
88
93
 
94
+ - **Host-side cwd alias for session indexing.** `dsh-workspace` indexes sessions by `realpath(header.cwd)` and `session-persistence-jsonl` rejects a header whose cwd is not natively absolute, so cross-OS visibility currently requires the plugin to rewrite a local copy of the header and move the file into the projected project directory. A host-level alias/foreign-root mapping (or a `SessionHeader` cwd override at read time) would let the mirror stay byte-identical everywhere and drop the projection state.
95
+
89
96
  - **Session-directory layout version marker.** The mirror maps fork files back to sessions by path shape (`<projectKey>/<sessionId>/<file>` plus the legacy flat form). A version marker in the session-directory layout would let a future plugin declare which layout it understands instead of sniffing segment shapes; recorded here per the 0.1.6 adaptation review (P2, no code change requested).
90
97
 
91
98
  ## Backend vocabulary
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] - 2026-11-13
4
+
5
+ ### Added
6
+
7
+ - **`cwdMap`: restore-time cwd projection so cross-OS sessions appear in the host workspace list (#28).** A session synced from another platform carries a `header.cwd` that is not natively absolute on the receiving host, so `@deepseek-ai/dsh-workspace` never indexes it (`realpathNormalize` refuses it) and `session-persistence-jsonl` cannot even parse the header — the bytes arrived but the session stayed invisible. `cwdMap: [{ from, to }]` maps an origin prefix to a local path; the longest matching prefix wins and prefixes end on a path-segment boundary (Windows prefixes compare case-insensitively, so `C:\Users\me2` does not match `C:\Users\me`). Restore rewrites the first frame of the **local copy** only and lands it at `<projectKey(mapped cwd)>/<sessionId>/<file>`, creating the mapped directory; the mirror keeps the origin device's bytes and a push reattaches the original header frame, so the other device still sees byte-identical appends and no meaningless conflicts. Cross-platform cwds with no entry land **read-only** under `<sessionRoot>/--unmapped--` and `sync_status` counts them (`cwdUnmapped`).
8
+ - **`followSessionSymlinks` (default `false`) and symlink diagnostics (#30).** Android/proot `link2symlink` reports host-written session files as symbolic links whose bytes are still readable, so the strict "never follow symlinks" mirror silently dropped every native session. `sync_status` now reports `skippedSymlinks` / `skippedSymlinkPaths` / `followedSymlinks` and push results carry the same warning; opting in follows only links whose `realpath` stays inside `sessionRoot` — links that escape are always skipped and counted.
9
+ - The auto-push listener logs its registration once at mount (`auto push listener registered …`), so a host that never delivers `session/event` is diagnosable from the outside (#30).
10
+
11
+ ### Changed
12
+
13
+ - `sync_status` gains `skippedSymlinks`, `skippedSymlinkPaths`, `followedSymlinks`, `cwdMapped`, `cwdUnmapped`, `cwdProjectionSkipped`, `cwdPlaceholder`, and `followSessionSymlinks`; `sync_pull` gains `cwdMapped` / `cwdUnmapped`; `sync_push` gains `skippedSymlinks` / `skippedSymlinkPaths`. All new fields are optional and JSON-safe.
14
+ - `@deepseek-ai/dsh-session-persistence-jsonl` joins the devDependencies as a test gate: the projection tests create a session log with a Windows cwd, restore it, and assert the **real host backend** `stat()`/`list()` accepts the projected layout (the host validates `<root>/<projectKey(header.cwd)>/<sessionId>/<file>`, which pins our `projectKey` implementation and directory layout).
15
+
3
16
  ## [0.2.33] - 2026-11-13
4
17
 
5
18
  ### Fixed
package/README.en.md CHANGED
@@ -154,10 +154,12 @@ Most-used keys:
154
154
  | `branch` | `main` | Remote branch name |
155
155
  | `autoPushOnTurnEnd` | `false` | Push after every closed turn |
156
156
  | `pullIntervalMinutes` | `0` | Periodic pull every N minutes (`0` = off, max `10080`) |
157
+ | `cwdMap` | `[]` | Restore-time cwd projection `[{from, to}]` (longest prefix wins; unmatched cross-platform cwds go read-only under `<sessionRoot>/--unmapped--`) |
158
+ | `followSessionSymlinks` | `false` | Follow symbolic links whose realpath stays inside `sessionRoot` (Android/proot diagnostics) |
157
159
  | `confirmVia` | `auto` | Confirmation channel: `auto` (userQuestions first, then approval), `userQuestions`, `approval` |
158
160
 
159
161
  <details>
160
- <summary>Full configuration table (21 keys)</summary>
162
+ <summary>Full configuration table (23 keys)</summary>
161
163
 
162
164
  | Key | Default | Meaning |
163
165
  |---|---|---|
@@ -174,6 +176,8 @@ Most-used keys:
174
176
  | `autoPullOnStart` | `false` | Pull once when the plugin mounts (config is the grant; no re-confirm) |
175
177
  | `autoPushOnTurnEnd` | `false` | Push after every closed turn |
176
178
  | `pullIntervalMinutes` | `0` | Periodic pull every N minutes (`0` = off, max `10080`) |
179
+ | `cwdMap` | `[]` | Restore-time cwd projection `[{from, to}]` (longest prefix wins; unmatched cross-platform cwds go read-only under `<sessionRoot>/--unmapped--`) |
180
+ | `followSessionSymlinks` | `false` | Follow symbolic links whose realpath stays inside `sessionRoot` (Android/proot diagnostics) |
177
181
  | `confirmVia` | `auto` | Confirmation channel: `auto` (userQuestions first, then approval), `userQuestions`, `approval` |
178
182
  | `graceMs` | `10000` | Grace period for git kills (ms) |
179
183
  | `commandTimeoutMs` | `120000` | Per-command timeout (ms) |
@@ -268,6 +272,27 @@ What it does **not** protect (the boundary):
268
272
 
269
273
  Baseline: with `backend: git` (the default), session bytes are stored unencrypted in **your** git remote — use a private repository.
270
274
 
275
+ ### Cross-OS sessions and cwd projection
276
+
277
+ A Windows session synced to Linux (or the reverse) carries a `header.cwd` that is not a fully qualified path on the receiving host: `dsh-workspace` indexes sessions through `realpath(header.cwd)`, and `session-persistence-jsonl` cannot even parse a header whose cwd is not natively absolute. Map the origin prefix to a local path:
278
+
279
+ ```yaml
280
+ cwdMap:
281
+ - from: 'C:\Users\me'
282
+ to: /home/me/win
283
+ ```
284
+
285
+ - The longest matching prefix wins, and prefixes end on a path-segment boundary (`C:\Users\me2` does not match `C:\Users\me`).
286
+ - Restore projects only the **local copy**: its first frame carries the local cwd and lands in the host's project directory, so the session shows up in the workspace list. The mirror keeps the origin device's bytes; a push reattaches the original header frame, so the other device still sees byte-identical appends and never gets meaningless conflicts.
287
+ - A cross-platform cwd with no entry lands under `<sessionRoot>/--unmapped--`: **visible but read-only** (`sync_status` reports it as `cwdUnmapped`, and local edits are never pushed). Add a `cwdMap` entry and pull again to turn it into a continuable local session.
288
+
289
+ ### Symbolic links (Android/proot)
290
+
291
+ The mirror **never follows symbolic links** by default (a safety boundary). Android/proot's `link2symlink` reports host-written session files as symlinks (`readdir` says link, `readlink` is empty, the bytes are readable), so the phone's own sessions never reach the mirror. Diagnostics and opt-in following:
292
+
293
+ - `sync_status` reports `skippedSymlinks` / `skippedSymlinkPaths` (count and path samples) and `followedSymlinks`; push results carry the same warning.
294
+ - `followSessionSymlinks: true` (default `false`) follows only links whose `realpath` stays inside `sessionRoot`; links that escape are always skipped and counted.
295
+
271
296
  ## Known limitations
272
297
 
273
298
  - **Encryption is optional, and age is an external dependency.** `backend: encrypted` adds an age layer (see "Encryption & threat model" above); a missing `age` or empty `ageRecipient`/`ageIdentity` warns explicitly and degrades to plaintext, and a passphrase-protected identity cannot be used (decryption would block on a TTY prompt, so it fails closed). With `backend: git` (the default), session bytes are stored unencrypted in **your** git remote — use a private repository.
package/README.es.md CHANGED
@@ -154,10 +154,12 @@ Claves más usadas:
154
154
  | `branch` | `main` | Nombre de la rama remota |
155
155
  | `autoPushOnTurnEnd` | `false` | Push tras cada turno cerrado |
156
156
  | `pullIntervalMinutes` | `0` | Pull periódico cada N minutos (`0` = apagado, máximo `10080`) |
157
+ | `cwdMap` | `[]` | Proyección de cwd en la restauración `[{from, to}]` (gana el prefijo más largo; los cwd multiplataforma sin coincidencia quedan en solo lectura bajo `<sessionRoot>/--unmapped--`) |
158
+ | `followSessionSymlinks` | `false` | Sigue enlaces simbólicos cuyo realpath permanece dentro de `sessionRoot` (diagnóstico para Android/proot) |
157
159
  | `confirmVia` | `auto` | Canal de confirmación: `auto` (primero userQuestions, luego approval), `userQuestions`, `approval` |
158
160
 
159
161
  <details>
160
- <summary>Tabla de configuración completa (21 claves)</summary>
162
+ <summary>Tabla de configuración completa (23 claves)</summary>
161
163
 
162
164
  | Clave | Valor por defecto | Significado |
163
165
  |---|---|---|
@@ -174,6 +176,8 @@ Claves más usadas:
174
176
  | `autoPullOnStart` | `false` | Pull una vez al montar el plugin (la configuración es la autorización; no reconfirma) |
175
177
  | `autoPushOnTurnEnd` | `false` | Push tras cada turno cerrado |
176
178
  | `pullIntervalMinutes` | `0` | Pull periódico cada N minutos (`0` = apagado, máximo `10080`) |
179
+ | `cwdMap` | `[]` | Proyección de cwd en la restauración `[{from, to}]` (gana el prefijo más largo; los cwd multiplataforma sin coincidencia quedan en solo lectura bajo `<sessionRoot>/--unmapped--`) |
180
+ | `followSessionSymlinks` | `false` | Sigue enlaces simbólicos cuyo realpath permanece dentro de `sessionRoot` (diagnóstico para Android/proot) |
177
181
  | `confirmVia` | `auto` | Canal de confirmación: `auto` (primero userQuestions, luego approval), `userQuestions`, `approval` |
178
182
  | `graceMs` | `10000` | Margen de gracia para matar git (ms) |
179
183
  | `commandTimeoutMs` | `120000` | Timeout por comando (ms) |
@@ -268,6 +272,27 @@ Qué **no** protege (la frontera):
268
272
 
269
273
  Línea base: con `backend: git` (el predeterminado), los bytes de sesión se almacenan sin cifrar en **tu** remoto git — usa un repositorio privado.
270
274
 
275
+ ### Sesiones multiplataforma y proyección de cwd
276
+
277
+ Una sesión de Windows sincronizada en Linux (o al revés) lleva un `header.cwd` que no es una ruta absoluta nativa en el host receptor: `dsh-workspace` indexa las sesiones con `realpath(header.cwd)`, y `session-persistence-jsonl` ni siquiera puede analizar un header cuyo cwd no sea absoluto nativo. Asigna el prefijo de origen a una ruta local:
278
+
279
+ ```yaml
280
+ cwdMap:
281
+ - from: 'C:\Users\me'
282
+ to: /home/me/win
283
+ ```
284
+
285
+ - Gana el prefijo más largo y los prefijos deben terminar en un límite de segmento (`C:\Users\me2` no coincide con `C:\Users\me`).
286
+ - La restauración solo proyecta la **copia local**: su primer frame lleva el cwd local y aterriza en el directorio de proyecto del host, así la sesión aparece en la lista de workspaces. El espejo conserva los bytes del dispositivo de origen; un push vuelve a enganchar el frame de cabecera original, de modo que el otro dispositivo sigue viendo appends idénticos byte a byte y nunca recibe conflictos sin sentido.
287
+ - Un cwd multiplataforma sin entrada cae en `<sessionRoot>/--unmapped--`: **visible pero de solo lectura** (`sync_status` lo informa como `cwdUnmapped` y las ediciones locales nunca se suben). Añade una entrada `cwdMap` y vuelve a hacer pull para convertirlo en una sesión local continuable.
288
+
289
+ ### Enlaces simbólicos (Android/proot)
290
+
291
+ El espejo **nunca sigue enlaces simbólicos** por defecto (límite de seguridad). El `link2symlink` de Android/proot informa los archivos de sesión escritos por el host como enlaces simbólicos (`readdir` dice enlace, `readlink` está vacío, los bytes son legibles), así que las sesiones propias del teléfono nunca llegan al espejo. Diagnóstico y seguimiento opcional:
292
+
293
+ - `sync_status` informa `skippedSymlinks` / `skippedSymlinkPaths` (recuento y muestras de rutas) y `followedSymlinks`; el resultado de push lleva el mismo aviso.
294
+ - `followSessionSymlinks: true` (por defecto `false`) sigue solo los enlaces cuyo `realpath` permanece dentro de `sessionRoot`; los enlaces que escapan siempre se omiten y se cuentan.
295
+
271
296
  ## Limitaciones conocidas
272
297
 
273
298
  - **El cifrado es opcional y age es una dependencia externa.** `backend: encrypted` añade una capa age (ver «Cifrado y modelo de amenazas» arriba); si falta `age` o `ageRecipient`/`ageIdentity` están vacíos, avisa explícitamente y cae a texto plano, y una identidad protegida con frase de contraseña no se puede usar (el descifrado bloquearía en un prompt TTY, así que falla en cerrado). Con `backend: git` (el predeterminado), los bytes de sesión se almacenan sin cifrar en **tu** remoto git — usa un repositorio privado.
package/README.hi.md CHANGED
@@ -154,10 +154,12 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
154
154
  | `branch` | `main` | रिमोट branch का नाम |
155
155
  | `autoPushOnTurnEnd` | `false` | हर बंद टर्न के बाद push |
156
156
  | `pullIntervalMinutes` | `0` | हर N मिनट में आवधिक pull (`0` = बंद, अधिकतम `10080`) |
157
+ | `cwdMap` | `[]` | पुनर्स्थापन के समय cwd प्रोजेक्शन `[{from, to}]` (सबसे लंबा प्रीफ़िक्स जीतता है; बिना मेल वाले क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` के नीचे केवल-पढ़ने योग्य रहते हैं) |
158
+ | `followSessionSymlinks` | `false` | उन सिम्बोलिक लिंक का पालन करें जिनका realpath `sessionRoot` के भीतर ही रहता है (Android/proot निदान) |
157
159
  | `confirmVia` | `auto` | पुष्टि चैनल: `auto` (पहले userQuestions, फिर approval), `userQuestions`, `approval` |
158
160
 
159
161
  <details>
160
- <summary>पूरी कॉन्फ़िगरेशन तालिका (21 कुंजियाँ)</summary>
162
+ <summary>पूरी कॉन्फ़िगरेशन तालिका (23 कुंजियाँ)</summary>
161
163
 
162
164
  | कुंजी | डिफ़ॉल्ट | अर्थ |
163
165
  |---|---|---|
@@ -174,6 +176,8 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
174
176
  | `autoPullOnStart` | `false` | प्लगइन माउंट होने पर एक बार pull (कॉन्फ़िग ही अनुमति है; दोबारा पुष्टि नहीं) |
175
177
  | `autoPushOnTurnEnd` | `false` | हर बंद टर्न के बाद push |
176
178
  | `pullIntervalMinutes` | `0` | हर N मिनट में आवधिक pull (`0` = बंद, अधिकतम `10080`) |
179
+ | `cwdMap` | `[]` | पुनर्स्थापन के समय cwd प्रोजेक्शन `[{from, to}]` (सबसे लंबा प्रीफ़िक्स जीतता है; बिना मेल वाले क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` के नीचे केवल-पढ़ने योग्य रहते हैं) |
180
+ | `followSessionSymlinks` | `false` | उन सिम्बोलिक लिंक का पालन करें जिनका realpath `sessionRoot` के भीतर ही रहता है (Android/proot निदान) |
177
181
  | `confirmVia` | `auto` | पुष्टि चैनल: `auto` (पहले userQuestions, फिर approval), `userQuestions`, `approval` |
178
182
  | `graceMs` | `10000` | git को समाप्त करने की छूट अवधि (ms) |
179
183
  | `commandTimeoutMs` | `120000` | प्रति-कमांड timeout (ms) |
@@ -268,6 +272,27 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
268
272
 
269
273
  आधार रेखा: `backend: git` (डिफ़ॉल्ट) के साथ सत्र बाइट्स **आपके** git रिमोट में बिना एन्क्रिप्शन के संग्रहीत होते हैं — निजी रिपॉज़िटरी का उपयोग करें।
270
274
 
275
+ ### क्रॉस-प्लेटफ़ॉर्म सत्र और cwd प्रोजेक्शन
276
+
277
+ Windows से Linux (या उलटा) सिंक किए गए सत्र का `header.cwd` प्राप्तकर्ता होस्ट पर मूल निरपेक्ष पथ नहीं होता: `dsh-workspace` सत्रों को `realpath(header.cwd)` से अनुक्रमित करता है, और `session-persistence-jsonl` ऐसे header को पढ़ ही नहीं सकता जिसका cwd मूल रूप से निरपेक्ष न हो। स्रोत प्रीफ़िक्स को स्थानीय पथ पर मैप करें:
278
+
279
+ ```yaml
280
+ cwdMap:
281
+ - from: 'C:\Users\me'
282
+ to: /home/me/win
283
+ ```
284
+
285
+ - सबसे लंबा मिलता प्रीफ़िक्स जीतता है, और प्रीफ़िक्स पथ-खंड सीमा पर समाप्त होना चाहिए (`C:\Users\me2` `C:\Users\me` से मेल नहीं खाता)।
286
+ - पुनर्स्थापन केवल **स्थानीय प्रति** को प्रोजेक्ट करता है: उसका पहला फ़्रेम स्थानीय cwd लेकर होस्ट के प्रोजेक्ट निर्देशिका में जाता है, इसलिए सत्र workspace सूची में दिखता है। मिरर स्रोत डिवाइस के बाइट्स रखता है; push मूल हेडर फ़्रेम को फिर जोड़ देता है, इसलिए दूसरा डिवाइस अभी भी बाइट-दर-बाइट समान appends देखता है और व्यर्थ conflicts नहीं पाता।
287
+ - बिना मेल वाला क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` में जाता है: **दिखता है पर केवल-पढ़ने योग्य** (`sync_status` इसे `cwdUnmapped` बताता है, और स्थानीय बदलाव कभी push नहीं होते)। `cwdMap` प्रविष्टि जोड़कर फिर pull करें तो यह जारी रखने योग्य स्थानीय सत्र बन जाता है।
288
+
289
+ ### सिम्बोलिक लिंक (Android/proot)
290
+
291
+ मिरर डिफ़ॉल्ट रूप से **सिम्बोलिक लिंक का पालन कभी नहीं करता** (सुरक्षा सीमा)। Android/proot का `link2symlink` होस्ट द्वारा लिखी सत्र फ़ाइलों को सिम्बोलिक लिंक बताता है (`readdir` लिंक कहता है, `readlink` खाली है, बाइट्स पढ़े जा सकते हैं), इसलिए फ़ोन के अपने सत्र मिरर तक कभी नहीं पहुँचते। निदान और वैकल्पिक पालन:
292
+
293
+ - `sync_status` अब `skippedSymlinks` / `skippedSymlinkPaths` (गिनती और पथ नमूने) तथा `followedSymlinks` बताता है; push परिणाम में वही चेतावनी आती है।
294
+ - `followSessionSymlinks: true` (डिफ़ॉल्ट `false`) केवल उन लिंक का पालन करता है जिनका `realpath` `sessionRoot` के भीतर रहता है; बाहर जाने वाले लिंक हमेशा छोड़े और गिने जाते हैं।
295
+
271
296
  ## ज्ञात सीमाएँ
272
297
 
273
298
  - **एन्क्रिप्शन वैकल्पिक है, और age बाहरी निर्भरता है।** `backend: encrypted` age परत जोड़ता है (ऊपर «एन्क्रिप्शन और ख़तरा मॉडल» देखें); `age` न होना या `ageRecipient`/`ageIdentity` का खाली होना स्पष्ट चेतावनी देकर plaintext पर अवनति करता है, और पासफ़्रेज़-संरक्षित identity उपयोग नहीं की जा सकती (डिक्रिप्शन TTY प्रॉम्प्ट पर अटक जाता, इसलिए बंद होकर विफल होता है)। `backend: git` (डिफ़ॉल्ट) के साथ सत्र बाइट्स **आपके** git रिमोट में बिना एन्क्रिप्शन के रहते हैं — निजी रिपॉज़िटरी का उपयोग करें।
package/README.md CHANGED
@@ -154,10 +154,12 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
154
154
  | `branch` | `main` | 远端分支名 |
155
155
  | `autoPushOnTurnEnd` | `false` | 每个关闭轮次后推送 |
156
156
  | `pullIntervalMinutes` | `0` | 每 N 分钟周期拉取(`0` = 关闭,最大 `10080`) |
157
+ | `cwdMap` | `[]` | 恢复期 cwd 投影表 `[{from, to}]`(最长前缀优先;未命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`,只读) |
158
+ | `followSessionSymlinks` | `false` | 是否跟随 realpath 仍在 `sessionRoot` 内的符号链接(Android/proot 诊断) |
157
159
  | `confirmVia` | `auto` | 确认通道:`auto`(优先 userQuestions,其次 approval)、`userQuestions`、`approval` |
158
160
 
159
161
  <details>
160
- <summary>完整配置表(21 个键)</summary>
162
+ <summary>完整配置表(23 个键)</summary>
161
163
 
162
164
  | 键 | 默认值 | 含义 |
163
165
  |---|---|---|
@@ -174,6 +176,8 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
174
176
  | `autoPullOnStart` | `false` | 插件挂载时拉取一次(配置即授权,不再确认) |
175
177
  | `autoPushOnTurnEnd` | `false` | 每个关闭轮次后推送 |
176
178
  | `pullIntervalMinutes` | `0` | 每 N 分钟周期拉取(`0` = 关闭,最大 `10080`) |
179
+ | `cwdMap` | `[]` | 恢复期 cwd 投影表 `[{from, to}]`(最长前缀优先;未命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`,只读) |
180
+ | `followSessionSymlinks` | `false` | 是否跟随 realpath 仍在 `sessionRoot` 内的符号链接(Android/proot 诊断) |
177
181
  | `confirmVia` | `auto` | 确认通道:`auto`(优先 userQuestions,其次 approval)、`userQuestions`、`approval` |
178
182
  | `graceMs` | `10000` | git 终止宽限(毫秒) |
179
183
  | `commandTimeoutMs` | `120000` | 单条命令超时(毫秒) |
@@ -268,6 +272,27 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
268
272
 
269
273
  基线:`backend: git`(默认)下,会话字节以未加密形式存放在**你的** git 远端——请使用私有仓库。
270
274
 
275
+ ### 跨平台会话与 cwd 投影
276
+
277
+ Windows ↔ Linux 会话的 `header.cwd` 在另一台机器上不是本机绝对路径:宿主 `dsh-workspace` 按 `realpath(header.cwd)` 建索引,`session-persistence-jsonl` 更是 header 解析失败就完全看不到会话。用 `cwdMap` 把源设备前缀映射到本机路径:
278
+
279
+ ```yaml
280
+ cwdMap:
281
+ - from: 'C:\Users\me'
282
+ to: /home/me/win
283
+ ```
284
+
285
+ - 最长前缀优先,前缀必须结束在路径段边界上(`C:\Users\me2` 不匹配 `C:\Users\me`)。
286
+ - 恢复时只投影**本地副本**:首帧 cwd 改写为本机路径、文件落到宿主布局的项目目录,因此会话出现在 workspace 列表里。同步仓库里的字节始终是源设备的 cwd;推送时把原首帧接回,对端看到的仍是逐字节 append,不会产生无意义分叉。
287
+ - 没有命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`:会话**可见但只读**,`sync_status` 的 `cwdUnmapped` 会计数,本地改动不会推送。给它补一条 `cwdMap` 后重新 pull 即可变成可继续的本地会话。
288
+
289
+ ### 符号链接(Android/proot)
290
+
291
+ 默认**绝不跟随符号链接**(安全边界)。Android/proot 的 `link2symlink` 会把宿主写入的会话文件报成符号链接(`readdir` 说是链接、`readlink` 为空、内容可读),导致手机自己的会话永远不进镜像。诊断与可选跟随:
292
+
293
+ - `sync_status` 新增 `skippedSymlinks` / `skippedSymlinkPaths`(数量与路径样本)、`followedSymlinks`,push 结果也会带同类 warning;
294
+ - `followSessionSymlinks: true`(默认 `false`)只跟随 `realpath` 仍落在 `sessionRoot` 内的链接,越界链接一律跳过并计数。
295
+
271
296
  ## 已知限制
272
297
 
273
298
  - **加密可选、age 为外部依赖。** `backend: encrypted` 增加一层 age 加密(见上文「加密与威胁模型」);`age` 缺失或 `ageRecipient`/`ageIdentity` 为空时显式告警并降级明文,口令保护的 identity 不可用(解密会阻塞在 TTY 提示上,因此失败关闭)。`backend: git`(默认)下,会话字节以未加密形式存放在**你的** git 远端——请使用私有仓库。
package/README.pt.md CHANGED
@@ -154,10 +154,12 @@ Chaves mais usadas:
154
154
  | `branch` | `main` | Nome do branch remoto |
155
155
  | `autoPushOnTurnEnd` | `false` | Push após cada turno fechado |
156
156
  | `pullIntervalMinutes` | `0` | Pull periódico a cada N minutos (`0` = desligado, máximo `10080`) |
157
+ | `cwdMap` | `[]` | Projeção de cwd na restauração `[{from, to}]` (o prefixo mais longo vence; cwds multiplataforma sem entrada ficam somente leitura em `<sessionRoot>/--unmapped--`) |
158
+ | `followSessionSymlinks` | `false` | Segue links simbólicos cujo realpath permanece dentro de `sessionRoot` (diagnóstico Android/proot) |
157
159
  | `confirmVia` | `auto` | Canal de confirmação: `auto` (userQuestions primeiro, depois approval), `userQuestions`, `approval` |
158
160
 
159
161
  <details>
160
- <summary>Tabela de configuração completa (21 chaves)</summary>
162
+ <summary>Tabela de configuração completa (23 chaves)</summary>
161
163
 
162
164
  | Chave | Padrão | Significado |
163
165
  |---|---|---|
@@ -174,6 +176,8 @@ Chaves mais usadas:
174
176
  | `autoPullOnStart` | `false` | Pull uma vez ao montar o plugin (a configuração é a autorização; sem reconfirmação) |
175
177
  | `autoPushOnTurnEnd` | `false` | Push após cada turno fechado |
176
178
  | `pullIntervalMinutes` | `0` | Pull periódico a cada N minutos (`0` = desligado, máximo `10080`) |
179
+ | `cwdMap` | `[]` | Projeção de cwd na restauração `[{from, to}]` (o prefixo mais longo vence; cwds multiplataforma sem entrada ficam somente leitura em `<sessionRoot>/--unmapped--`) |
180
+ | `followSessionSymlinks` | `false` | Segue links simbólicos cujo realpath permanece dentro de `sessionRoot` (diagnóstico Android/proot) |
177
181
  | `confirmVia` | `auto` | Canal de confirmação: `auto` (userQuestions primeiro, depois approval), `userQuestions`, `approval` |
178
182
  | `graceMs` | `10000` | Período de carência para matar o git (ms) |
179
183
  | `commandTimeoutMs` | `120000` | Timeout por comando (ms) |
@@ -268,6 +272,27 @@ O que ela **não** protege (a fronteira):
268
272
 
269
273
  Linha de base: com `backend: git` (o padrão), os bytes de sessão são armazenados sem criptografia no **seu** remoto git — use um repositório privado.
270
274
 
275
+ ### Sessões multiplataforma e projeção de cwd
276
+
277
+ Uma sessão do Windows sincronizada no Linux (ou o contrário) carrega um `header.cwd` que não é um caminho absoluto nativo no host receptor: o `dsh-workspace` indexa sessões via `realpath(header.cwd)`, e o `session-persistence-jsonl` nem consegue analisar um header cujo cwd não seja absoluto nativo. Mapeie o prefixo de origem para um caminho local:
278
+
279
+ ```yaml
280
+ cwdMap:
281
+ - from: 'C:\Users\me'
282
+ to: /home/me/win
283
+ ```
284
+
285
+ - O prefixo mais longo vence, e os prefixos terminam num limite de segmento (`C:\Users\me2` não corresponde a `C:\Users\me`).
286
+ - A restauração projeta apenas a **cópia local**: o primeiro frame leva o cwd local e cai no diretório de projeto do host, então a sessão aparece na lista de workspaces. O espelho mantém os bytes do dispositivo de origem; um push reanexa o frame de cabeçalho original, então o outro dispositivo continua vendo appends idênticos byte a byte e nunca recebe conflitos sem sentido.
287
+ - Um cwd multiplataforma sem entrada vai para `<sessionRoot>/--unmapped--`: **visível mas somente leitura** (`sync_status` o informa como `cwdUnmapped`, e edições locais nunca são enviadas). Adicione uma entrada `cwdMap` e faça pull de novo para torná-lo uma sessão local continuável.
288
+
289
+ ### Links simbólicos (Android/proot)
290
+
291
+ O espelho **nunca segue links simbólicos** por padrão (limite de segurança). O `link2symlink` do Android/proot informa os arquivos de sessão escritos pelo host como links simbólicos (`readdir` diz link, `readlink` está vazio, os bytes são legíveis), então as sessões do próprio telefone nunca chegam ao espelho. Diagnóstico e seguimento opcional:
292
+
293
+ - `sync_status` informa `skippedSymlinks` / `skippedSymlinkPaths` (contagem e amostras de caminhos) e `followedSymlinks`; o resultado do push leva o mesmo aviso.
294
+ - `followSessionSymlinks: true` (padrão `false`) segue apenas links cujo `realpath` permanece dentro de `sessionRoot`; links que escapam são sempre ignorados e contados.
295
+
271
296
  ## Limitações conhecidas
272
297
 
273
298
  - **A criptografia é opcional e o age é uma dependência externa.** `backend: encrypted` adiciona uma camada age (ver «Criptografia e modelo de ameaças» acima); se o `age` faltar ou `ageRecipient`/`ageIdentity` estiverem vazios, avisa explicitamente e cai para texto plano, e uma identidade protegida por frase de senha não pode ser usada (a descriptografia bloquearia num prompt TTY, então falha fechada). Com `backend: git` (o padrão), os bytes de sessão são armazenados sem criptografia no **seu** remoto git — use um repositório privado.
package/cordis.patch.yml CHANGED
@@ -40,6 +40,17 @@
40
40
  # auto (userQuestions first, then approval) · userQuestions · approval.
41
41
  # Read-only surfaces (status/diff/log) never ask.
42
42
  confirmVia: auto
43
+ # Restore-time cwd projection (cross-OS sessions). Each entry maps an
44
+ # origin-device prefix to a local path; longest matching prefix wins and
45
+ # prefixes end on a path-segment boundary (C:\Users\me2 does not match
46
+ # C:\Users\me). The mirror keeps the origin device's bytes; only the
47
+ # restored local copy carries the local cwd. Cross-platform cwds with no
48
+ # entry are shown read-only under <sessionRoot>/--unmapped--.
49
+ cwdMap: []
50
+ # Mirror symbolic links whose realpath stays inside sessionRoot
51
+ # (Android/proot link2symlink hosts). Default false keeps "never follow
52
+ # symlinks"; skipped links are counted and listed in sync_status.
53
+ followSessionSymlinks: false
43
54
  # Subprocess tuning: grace period for git kills, per-command timeout,
44
55
  # and the per-stream collected-output cap.
45
56
  graceMs: 10000
package/index.mjs CHANGED
@@ -57,6 +57,19 @@ import { collectStatus } from './lib/status.mjs'
57
57
  import { renderDiff, renderPull, renderPush, renderStatus, errorValue } from './lib/render.mjs'
58
58
  import { confirmSync, hasOpenTurn, makeEventGate, maybeAppendSessionEvent, openTurnFromProjection } from './lib/gate.mjs'
59
59
  import { sessionSyncDomainSpec } from './lib/domain.mjs'
60
+ import {
61
+ matchCwdMap,
62
+ normalizeCwdMap,
63
+ projectCwd,
64
+ projectKey,
65
+ projectedRelOf,
66
+ } from './lib/cwdmap.mjs'
67
+ import {
68
+ canonicalizeProjectedFile,
69
+ planRestoreFile,
70
+ readProjectionState,
71
+ } from './lib/projection.mjs'
72
+ import { readSessionHeader } from './lib/sessionlog.mjs'
60
73
 
61
74
  export const name = PLUGIN_NAME
62
75
 
@@ -107,6 +120,8 @@ export function probeIgnorableAppend() {
107
120
  * @property {boolean} [autoPushOnTurnEnd] 每个 turn/end 后自动推送(配置即授权)。
108
121
  * @property {number} [pullIntervalMinutes] 周期自动拉取间隔分钟(0 = 关闭)。
109
122
  * @property {'auto'|'userQuestions'|'approval'} [confirmVia] 确认通道(auto 优先 userQuestions)。
123
+ * @property {ReadonlyArray<{from: string, to: string}>} [cwdMap] 恢复期 cwd 投影表(最长前缀优先;未命中的跨平台 cwd 归一到 sessionRoot/--unmapped--)。
124
+ * @property {boolean} [followSessionSymlinks] 镜像时是否跟随 realpath 仍在 sessionRoot 内的符号链接(默认 false)。
110
125
  * @property {number} [graceMs] git 子进程终止宽限(ms)。
111
126
  * @property {number} [commandTimeoutMs] 单条 git 命令超时(ms)。
112
127
  * @property {number} [maxOutputBytes] git 输出单流收集上限(字节)。
@@ -132,6 +147,11 @@ export const Config = Schema.object({
132
147
  autoPushOnTurnEnd: Schema.boolean().default(DEFAULTS.AUTO_PUSH_ON_TURN_END),
133
148
  pullIntervalMinutes: Schema.number().default(DEFAULTS.PULL_INTERVAL_MINUTES),
134
149
  confirmVia: Schema.union(Object.values(CONFIRM_CHANNELS)).default(DEFAULTS.CONFIRM_VIA),
150
+ cwdMap: Schema.array(Schema.object({
151
+ from: Schema.string().required(),
152
+ to: Schema.string().required(),
153
+ })).default([...DEFAULTS.CWD_MAP]),
154
+ followSessionSymlinks: Schema.boolean().default(DEFAULTS.FOLLOW_SESSION_SYMLINKS),
135
155
  graceMs: Schema.number().default(DEFAULTS.GRACE_MS),
136
156
  commandTimeoutMs: Schema.number().default(DEFAULTS.COMMAND_TIMEOUT_MS),
137
157
  maxOutputBytes: Schema.number().default(DEFAULTS.MAX_OUTPUT_BYTES),
@@ -162,6 +182,8 @@ export function resolveConfig(config = {}) {
162
182
  autoPushOnTurnEnd: config.autoPushOnTurnEnd ?? DEFAULTS.AUTO_PUSH_ON_TURN_END,
163
183
  pullIntervalMinutes: config.pullIntervalMinutes ?? DEFAULTS.PULL_INTERVAL_MINUTES,
164
184
  confirmVia: config.confirmVia ?? DEFAULTS.CONFIRM_VIA,
185
+ cwdMap: normalizeCwdMap(config.cwdMap ?? DEFAULTS.CWD_MAP),
186
+ followSessionSymlinks: config.followSessionSymlinks ?? DEFAULTS.FOLLOW_SESSION_SYMLINKS,
165
187
  graceMs: config.graceMs ?? DEFAULTS.GRACE_MS,
166
188
  commandTimeoutMs: config.commandTimeoutMs ?? DEFAULTS.COMMAND_TIMEOUT_MS,
167
189
  maxOutputBytes: config.maxOutputBytes ?? DEFAULTS.MAX_OUTPUT_BYTES,
@@ -204,6 +226,9 @@ export function resolveConfig(config = {}) {
204
226
  if (!Number.isInteger(resolved.pullIntervalMinutes) || resolved.pullIntervalMinutes < LIMITS.MIN_PULL_INTERVAL_MINUTES || resolved.pullIntervalMinutes > LIMITS.MAX_PULL_INTERVAL_MINUTES) {
205
227
  throw badConfig(`pullIntervalMinutes must be an integer in [${LIMITS.MIN_PULL_INTERVAL_MINUTES}, ${LIMITS.MAX_PULL_INTERVAL_MINUTES}]`)
206
228
  }
229
+ if (typeof resolved.followSessionSymlinks !== 'boolean') {
230
+ throw badConfig('followSessionSymlinks must be a boolean')
231
+ }
207
232
  if (typeof resolved.commitName !== 'string' || resolved.commitName.trim().length === 0) {
208
233
  throw badConfig('commitName must be a non-empty string')
209
234
  }
@@ -348,9 +373,9 @@ const TOOL_TEXT = {
348
373
  }
349
374
 
350
375
  /** sync_status 工具规范结果(与工具 schema 同构)。 */
351
- /** @typedef {{ok: boolean, branch: string, remote: string, head?: string, remoteHead?: string, ahead: number, behind: number, dirty: string[], forks: string[], diffStat: string, mergeInProgress: boolean, lastCommits: string[], lastPullAt?: number, lastPushAt?: number, lastError?: string, error?: string, warnings?: string[]}} StatusValue */
352
- /** @typedef {{ok: boolean, pulled?: boolean, merged?: boolean, adopted?: number, appended?: number, diverged?: number, forks?: string[], head?: string, error?: string, warnings?: string[]}} PullValue */
353
- /** @typedef {{ok: boolean, pushed?: boolean, head?: string, mirrored?: number, deleted?: number, remote?: string, error?: string, warnings?: string[]}} PushValue */
376
+ /** @typedef {{ok: boolean, branch: string, remote: string, head?: string, remoteHead?: string, ahead: number, behind: number, dirty: string[], forks: string[], diffStat: string, mergeInProgress: boolean, lastCommits: string[], lastPullAt?: number, lastPushAt?: number, lastError?: string, error?: string, skippedSymlinks?: number, skippedSymlinkPaths?: string[], followedSymlinks?: number, cwdMapped?: number, cwdUnmapped?: number, cwdProjectionSkipped?: number, cwdPlaceholder?: string, followSessionSymlinks?: boolean, warnings?: string[]}} StatusValue */
377
+ /** @typedef {{ok: boolean, pulled?: boolean, merged?: boolean, adopted?: number, appended?: number, diverged?: number, forks?: string[], head?: string, restored?: number, cwdMapped?: number, cwdUnmapped?: number, error?: string, warnings?: string[]}} PullValue */
378
+ /** @typedef {{ok: boolean, pushed?: boolean, head?: string, mirrored?: number, deleted?: number, remote?: string, skippedSymlinks?: number, skippedSymlinkPaths?: string[], error?: string, warnings?: string[]}} PushValue */
354
379
 
355
380
  /**
356
381
  * sync_status 工具定义(read-only:不确认、不触网)。
@@ -384,6 +409,14 @@ export function makeSyncStatusTool(engine, readMeta) {
384
409
  lastPushAt: { type: 'integer' },
385
410
  lastError: { type: 'string' },
386
411
  error: { type: 'string' },
412
+ skippedSymlinks: { type: 'integer' },
413
+ skippedSymlinkPaths: { type: 'array', items: { type: 'string' } },
414
+ followedSymlinks: { type: 'integer' },
415
+ cwdMapped: { type: 'integer' },
416
+ cwdUnmapped: { type: 'integer' },
417
+ cwdProjectionSkipped: { type: 'integer' },
418
+ cwdPlaceholder: { type: 'string' },
419
+ followSessionSymlinks: { type: 'boolean' },
387
420
  warnings: { type: 'array', items: { type: 'string' } },
388
421
  },
389
422
  },
@@ -437,6 +470,9 @@ export function makeSyncPullTool(deps) {
437
470
  diverged: { type: 'integer' },
438
471
  forks: { type: 'array', items: { type: 'string' } },
439
472
  head: { type: 'string' },
473
+ restored: { type: 'integer' },
474
+ cwdMapped: { type: 'integer' },
475
+ cwdUnmapped: { type: 'integer' },
440
476
  error: { type: 'string' },
441
477
  warnings: { type: 'array', items: { type: 'string' } },
442
478
  },
@@ -496,6 +532,8 @@ export function makeSyncPushTool(deps) {
496
532
  mirrored: { type: 'integer' },
497
533
  deleted: { type: 'integer' },
498
534
  remote: { type: 'string' },
535
+ skippedSymlinks: { type: 'integer' },
536
+ skippedSymlinkPaths: { type: 'array', items: { type: 'string' } },
499
537
  error: { type: 'string' },
500
538
  warnings: { type: 'array', items: { type: 'string' } },
501
539
  },
@@ -670,6 +708,8 @@ export function apply(ctx, config = {}) {
670
708
  remote: resolved.remote,
671
709
  branch: resolved.branch,
672
710
  deviceId: 'pending',
711
+ cwdMap: resolved.cwdMap,
712
+ followSessionSymlinks: resolved.followSessionSymlinks,
673
713
  reportMeta,
674
714
  reportError,
675
715
  logger,
@@ -865,6 +905,9 @@ export function apply(ctx, config = {}) {
865
905
 
866
906
  // turn/end 自动推送(配置即授权;每轮结束拉一次快照并推送)。
867
907
  if (resolved.autoPushOnTurnEnd) {
908
+ // #30:有些宿主(Android/proot 的 DSH Go)不发 session/event;把"监听器已
909
+ // 注册"记进日志,让外部可判断的是宿主事件还是插件注册。
910
+ logger.info(`auto push listener registered (session/event turn/end → push); pullIntervalMinutes=${resolved.pullIntervalMinutes}`)
868
911
  ctx.on('session/event', (session, event) => {
869
912
  if (event.type !== 'turn/end') return
870
913
  void engine.push().then(result => {
@@ -923,4 +966,14 @@ export {
923
966
  sessionSyncDomainSpec,
924
967
  registryUnavailable,
925
968
  errorValue,
969
+ // 跨平台 cwd 投影(#28)与符号链接诊断(#30)的复用/测试面。
970
+ normalizeCwdMap,
971
+ matchCwdMap,
972
+ projectCwd,
973
+ projectKey,
974
+ projectedRelOf,
975
+ planRestoreFile,
976
+ canonicalizeProjectedFile,
977
+ readProjectionState,
978
+ readSessionHeader,
926
979
  }
package/lib/constants.mjs CHANGED
@@ -17,6 +17,10 @@ export const MIRROR_DIR = 'sessions'
17
17
  // 仓库根下的设备身份文件(随机 UUID,提交进仓库供跨设备归属 fork)。
18
18
  export const DEVICE_FILE = 'device.txt'
19
19
 
20
+ // 恢复期 cwd 投影:无 cwdMap 命中的跨平台会话归一到 sessionRoot 下的这个占位
21
+ // 目录(可见但只读——只出现在本机索引里,永远不作为推送源)。
22
+ export const UNMAPPED_DIR = '--unmapped--'
23
+
20
24
  // 存储领域 state 表的单例键。
21
25
  export const STATE_KEY = 'singleton'
22
26
 
@@ -107,6 +111,8 @@ export const DEFAULTS = Object.freeze({
107
111
  AUTO_PUSH_ON_TURN_END: false,
108
112
  PULL_INTERVAL_MINUTES: 0,
109
113
  CONFIRM_VIA: CONFIRM_CHANNELS.AUTO,
114
+ CWD_MAP: Object.freeze([]),
115
+ FOLLOW_SESSION_SYMLINKS: false,
110
116
  GRACE_MS: 10000,
111
117
  COMMAND_TIMEOUT_MS: 120000,
112
118
  MAX_OUTPUT_BYTES: 262144,