dsh-plugin-wsl-env 0.24.0 → 0.26.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/CODE_OF_CONDUCT.md +85 -0
  3. package/CODE_OF_CONDUCT.zh.md +85 -0
  4. package/CONTRIBUTING.md +19 -3
  5. package/CONTRIBUTING.zh.md +200 -0
  6. package/README.md +18 -6
  7. package/SECURITY.md +12 -0
  8. package/SECURITY.zh.md +108 -0
  9. package/SUPPORT.md +2 -0
  10. package/SUPPORT.zh.md +99 -0
  11. package/client.js +409 -8
  12. package/cordis.patch.yml +17 -0
  13. package/docs/AGENT-PROTOCOL-V7.md +2 -2
  14. package/docs/API.md +2 -0
  15. package/docs/API.zh.md +38 -0
  16. package/docs/ARCHITECTURE.md +30 -9
  17. package/docs/ARCHITECTURE.zh.md +511 -0
  18. package/docs/COMPATIBILITY.md +2 -0
  19. package/docs/COMPATIBILITY.zh.md +117 -0
  20. package/docs/CONFIGURATION.md +45 -2
  21. package/docs/CONFIGURATION.zh.md +39 -3
  22. package/docs/DIAGNOSTICS.md +12 -2
  23. package/docs/DIAGNOSTICS.zh.md +5 -1
  24. package/docs/LIMITATIONS.md +60 -9
  25. package/docs/LIMITATIONS.zh.md +45 -9
  26. package/docs/MIGRATION.md +6 -3
  27. package/docs/MIGRATION.zh.md +91 -0
  28. package/docs/PEER-PARITY.md +63 -51
  29. package/docs/PERFORMANCE.md +2 -0
  30. package/docs/PERFORMANCE.zh.md +59 -0
  31. package/docs/QUICKSTART.md +21 -6
  32. package/docs/QUICKSTART.zh.md +16 -4
  33. package/docs/README.zh.md +28 -19
  34. package/docs/RELEASING.md +19 -14
  35. package/docs/REQUIREMENTS.zh.md +6 -3
  36. package/docs/ROADMAP-1.0.md +1 -1
  37. package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +1 -1
  38. package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
  39. package/docs/UPSTREAM-OPEN-IN-APP.md +33 -11
  40. package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
  41. package/docs/UPSTREAM-SESSION-NOTICE.md +7 -0
  42. package/docs/VALUE.md +146 -0
  43. package/docs/VALUE.zh.md +15 -13
  44. package/docs/root-fs-routing.md +1 -1
  45. package/lib/agent-confined.d.ts +7 -1
  46. package/lib/agent-confined.js +3 -3
  47. package/lib/auto-preset-seam.d.ts +45 -0
  48. package/lib/auto-preset-seam.js +47 -0
  49. package/lib/auto-preset.d.ts +33 -10
  50. package/lib/auto-preset.js +148 -44
  51. package/lib/bwrap.d.ts +14 -0
  52. package/lib/bwrap.js +11 -0
  53. package/lib/cwd-prompt.d.ts +41 -3
  54. package/lib/cwd-prompt.js +125 -8
  55. package/lib/doctor-live.d.ts +30 -0
  56. package/lib/doctor-live.js +37 -0
  57. package/lib/doctor-report.d.ts +50 -0
  58. package/lib/doctor-report.js +172 -0
  59. package/lib/fs-routing.d.ts +1 -1
  60. package/lib/fs-routing.js +1 -1
  61. package/lib/fs.d.ts +1 -1
  62. package/lib/fs.js +1 -1
  63. package/lib/index.d.ts +6 -1464
  64. package/lib/index.js +5 -2120
  65. package/lib/messages.d.ts +20 -1
  66. package/lib/messages.js +31 -3
  67. package/lib/open-in-app.d.ts +206 -0
  68. package/lib/open-in-app.js +300 -0
  69. package/lib/preflight.d.ts +7 -4
  70. package/lib/preflight.js +27 -13
  71. package/lib/preset-choice.d.ts +13 -0
  72. package/lib/preset-choice.js +18 -1
  73. package/lib/provider-common.d.ts +58 -0
  74. package/lib/provider-common.js +123 -0
  75. package/lib/sandbox-core.d.ts +1 -0
  76. package/lib/sandbox-core.js +4 -2
  77. package/lib/session-runtime.d.ts +7 -1
  78. package/lib/session-runtime.js +9 -2
  79. package/lib/shell.d.ts +1 -1
  80. package/lib/shell.js +1 -1
  81. package/lib/status.js +2 -1
  82. package/lib/writable-roots.d.ts +109 -0
  83. package/lib/writable-roots.js +257 -0
  84. package/lib/wsl-doctor-command.js +2 -1
  85. package/lib/wsl-doctor-tool.js +2 -2
  86. package/lib/wsl-filesystem.d.ts +692 -0
  87. package/lib/wsl-filesystem.js +897 -0
  88. package/lib/wsl-shell.d.ts +742 -0
  89. package/lib/wsl-shell.js +965 -0
  90. package/lib/wsl.d.ts +1 -1
  91. package/lib/wsl.js +1 -1
  92. package/package.json +48 -24
  93. package/scripts/doctor.mjs +1 -1
  94. package/scripts/profile-preset.mjs +17 -5
package/CHANGELOG.md CHANGED
@@ -16,6 +16,142 @@ were part of the record.
16
16
 
17
17
  ## [Unreleased]
18
18
 
19
+ ## [0.26.0] - 2026-11-12
20
+
21
+ One theme: adapted to DeepSeek Harness `0.2.2-rc.2` without patching the host —
22
+ installation stays plugin-only, and a WSL workspace gains the durable
23
+ open-in-app bridge plus a visible host-mode guard.
24
+
25
+ ### Changed
26
+
27
+ - **Installation is plugin-only: the plugin no longer patches the installed
28
+ desktop app.** The durable open-in-app bridge lives entirely in the
29
+ `wsl-open-in-app` row; the plugin never edits `resources/app.asar`. That
30
+ simplifies upgrades on both sides: replacing the desktop app cannot drop the
31
+ bridge, and updating the plugin needs only a reinstall and restart — no
32
+ archive re-patch, no post-upgrade re-patch checklist, and no local byte
33
+ patching of the host bundle. The shipped "Open in app" item still inherits
34
+ `ELECTRON_RUN_AS_NODE` and remains an upstream fix; the plugin's
35
+ **在 VS Code 中打开(WSL)** item works on an unpatched archive.
36
+ `test/probe/open-in-app-patch.sh` now only reports the bridge and archive
37
+ state instead of prescribing a patch.
38
+
39
+ - **Chinese versions of the community documentation.** README, QUICKSTART,
40
+ CONFIGURATION, LIMITATIONS, DIAGNOSTICS, COMPATIBILITY, PERFORMANCE,
41
+ MIGRATION, API, ARCHITECTURE, CONTRIBUTING, SECURITY, SUPPORT,
42
+ CODE_OF_CONDUCT and VALUE now ship with Chinese pages alongside English;
43
+ the npm tarball carries both sides of every pair.
44
+
45
+ - **Adapted to DeepSeek Harness `0.2.2-rc.2`.** The peer floor moves from
46
+ `>=0.2.2-rc.1` to `>=0.2.2-rc.2` and the dev pins follow the rc.2 line; the
47
+ web client declares the conversation, context-menu and session UI packages
48
+ its new surfaces use. The parity audit was re-walked against the rc.2
49
+ tarballs: `dsh-fs-local` is 1035 lines (its permission/IO arms now route
50
+ through `fsErrorFromErrno`), `dsh-bash-local` is byte-identical, and hashes
51
+ plus line references are in `docs/PEER-PARITY.md`.
52
+
53
+ ### Added
54
+
55
+ - **A durable open-in-app bridge.** The
56
+ `wsl-open-in-app` row registers `POST /api/wsl-env/open-in-app` on the
57
+ authenticated `/api` channel, and the Session header menu gains
58
+ **在 VS Code 中打开(WSL)**: it converts a WSL UNC workspace to its
59
+ `vscode-remote` URI and launches VS Code with `--folder-uri`, landing in
60
+ Remote-WSL instead of the 9p share. The route scrubs `ELECTRON_RUN_AS_NODE`
61
+ from the editor child's environment only; deleting it from the Host process
62
+ environment breaks Node-mode helpers such as the Windows Job runner. The
63
+ shipped "Open in app" item remains broken until upstream scrubs its own child
64
+ environment. The route refuses every non-WSL path.
65
+ `docs/UPSTREAM-OPEN-IN-APP.md` records the remaining upstream fix.
66
+ - **A distro workspace opened without the distro environment is now called out.**
67
+ When a workspace inside a WSL distro runs a non-WSL preset — recorded Windows
68
+ access (9p), a session that became interactive before adoption, or a profile
69
+ without the WSL preset — the session shows a persistent warning above the
70
+ composer naming the consequence (PowerShell commands, 9p file access, no Linux
71
+ toolchain) and the fix that applies: a one-click switch while the session is
72
+ blank, and the `windowsWorkspaces` correction once a turn has started. The
73
+ session header keeps a small **WSL工作区正以Windows模式打开** marker after the warning is
74
+ collapsed, the **WSL environment** panel lists the recorded directories, and
75
+ `auto-preset` logs the state and publishes it as a runtime-context entry so the
76
+ model does not assume a Linux toolchain. The reminder is plugin-owned client UI;
77
+ `docs/UPSTREAM-SESSION-NOTICE.md` still records the general upstream gap.
78
+
79
+ ### Fixed
80
+
81
+ - **The open-in-app route classifies a rejected launcher.** A launcher that
82
+ throws or rejects now answers the same `502` as a failed spawn instead of
83
+ letting an unhandled rejection escape the request handler.
84
+
85
+ - **The host-mode advisory and adoption fail open.** A settings read that
86
+ throws is treated like an unavailable record: the web reminder falls back to
87
+ the `wsl` target and warns instead of disappearing. `auto-preset` treats a
88
+ throwing volatile `windowsWorkspaces` getter as an empty record, so a config
89
+ read can neither silence the warning nor fail session creation, and a host
90
+ payload without an agent context still logs the advisory.
91
+
92
+ - **The creation-time preset binding calls the host's current API again.** The
93
+ host replaced `sessionController.agents.ensureSession(sessionId, cwd, …,
94
+ presetId)` with `agents.createSession({ cwd, agentPreset, … })` in 0.2.1; the
95
+ old wrapper had been silently inactive since, so a distro workspace's first
96
+ mount could still be the host preset until the deferred adoption ran. The row
97
+ now fills `agentPreset` in the create request (forwarding `sessionId` and
98
+ `reusable` untouched), retries with the caller's choice when the preset
99
+ registry refuses the target, and reports its state as the doctor's
100
+ `session.preset-seam` check — a warning instead of a log line when a future
101
+ host changes the shape again.
102
+
103
+ ## [0.25.0] - 2026-11-11
104
+
105
+ One theme: the model reads its prompt facts in the distro's own terms, and
106
+ `workspace-write` can grant the toolchain caches the policy had always
107
+ advertised.
108
+
109
+ ### Added
110
+
111
+ - **`writableRoots` on `wsl-shell` and `wsl-fs`.** `workspace-write` still grants
112
+ only the session workspace and the temp areas by default, but a row can now
113
+ name extra distro directories to bind read-write — the package-manager caches
114
+ npm, pnpm and cargo write under `$HOME`, and a linked worktree's shared Git
115
+ directory. Entries accept `~`/`~/...` and absolute Linux paths, must be
116
+ existing physical directories, and are ignored when already writable inside
117
+ the workspace, `/tmp` or `/dev/shm`, or nested inside another grant. The two
118
+ rows should carry the same list. `pnpm run preset --writable-roots
119
+ '~/.npm,~/.cache'` writes it into both nested rows of the printed block.
120
+ CONFIGURATION documents the cache recipes and the security trade-off.
121
+
122
+ - **Prompt adapters for the Windows-shaped prompt facts.** A WSL session now
123
+ carries a one-sentence `wsl:shell` note (the shell tool is named `bash` but
124
+ runs the distro's login shell with `-lc`), a POSIX-only `sandbox:policy` line
125
+ built from `ctx.sandboxPolicy` (mode, workspace and `additionalWritableRoots`,
126
+ no UNC path, plus the conditional `partial` enforcement note), and no
127
+ `harness:source` value — the host's `app.asar` Windows path is not a readable
128
+ checkout from the distro. The adapters are temporary and each names the
129
+ upstream change that retires it in
130
+ [docs/UPSTREAM-PROMPT-ADAPTERS.md](docs/UPSTREAM-PROMPT-ADAPTERS.md).
131
+
132
+ ### Changed
133
+
134
+ - **A ready preflight verdict is log-only.** Only a blocked `wsl-preflight`
135
+ verdict reaches the session's runtime context, and its remedy is marked as
136
+ operator action (ask the user before running anything). "The prerequisite is
137
+ usable" is not a model action; it stays in the host log, which still carries
138
+ the verdict on every session.
139
+ - **`ready` no longer promises the next command.** The `wsl_doctor` tool
140
+ description and its ready note say ready covers the checks in that run; the
141
+ older "the first command should succeed" was a step past what the probes
142
+ prove. The doctor and quickstart docs, and both READMEs, state the same.
143
+
144
+ ### Fixed
145
+
146
+ - **Confined WSL operations now honor the policy's `additionalWritableRoots`.**
147
+ The fence accepted a same-distro UNC extra root while the bwrap profile (and
148
+ the confined-write resident's cache key) dropped it, so an approved write
149
+ failed with `EROFS` or `FS_IO_ERROR`; a Linux-spelled entry was refused by the
150
+ fence even though it is the execution-world spelling. Both sources now resolve
151
+ through `lib/writable-roots.js` into one effective Linux list used by the
152
+ command profile, the confined-write resident and the session runtime, and the
153
+ session-runtime keys include the grants.
154
+
19
155
  ## [0.24.0] - 2026-11-10
20
156
 
21
157
  One theme: the diagnosis becomes something to act on — a sidebar panel
@@ -0,0 +1,85 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ [中文](CODE_OF_CONDUCT.zh.md)
4
+
5
+ ## Our Pledge
6
+
7
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
8
+
9
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
10
+
11
+ ## Our Standards
12
+
13
+ Examples of behavior that contributes to a positive environment for our community include:
14
+
15
+ * Demonstrating empathy and kindness toward other people
16
+ * Being respectful of differing opinions, viewpoints, and experiences
17
+ * Giving and gracefully accepting constructive feedback
18
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
19
+ * Focusing on what is best not just for us as individuals, but for the overall community
20
+
21
+ Examples of unacceptable behavior include:
22
+
23
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
24
+ * Trolling, insulting or derogatory comments, and personal or political attacks
25
+ * Public or private harassment
26
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
28
+
29
+ ## Enforcement Responsibilities
30
+
31
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
32
+
33
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
34
+
35
+ ## Scope
36
+
37
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
38
+
39
+ ## Enforcement
40
+
41
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported privately to the community leaders responsible for enforcement at the channel that [`SECURITY.md`](SECURITY.md) describes: [GitHub's private reporting form](https://github.com/Big-Dao/dsh-plugin-wsl-env/security/advisories/new), or, if that form is not available to you, an issue that asks a maintainer for a private channel without describing the incident in it. That channel is for conduct reports as well as vulnerability reports; the guidance in `SECURITY.md` on what to include in a report, and its response-time targets, are written for vulnerabilities and do not apply to a conduct report. All complaints will be reviewed and investigated promptly and fairly.
42
+
43
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
44
+
45
+ ## Enforcement Guidelines
46
+
47
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
48
+
49
+ ### 1. Correction
50
+
51
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
52
+
53
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
54
+
55
+ ### 2. Warning
56
+
57
+ **Community Impact**: A violation through a single incident or series of actions.
58
+
59
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
60
+
61
+ ### 3. Temporary Ban
62
+
63
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
64
+
65
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
66
+
67
+ ### 4. Permanent Ban
68
+
69
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
70
+
71
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
72
+
73
+ ## Attribution
74
+
75
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
76
+
77
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
78
+
79
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
83
+ [Mozilla CoC]: https://github.com/mozilla/diversity
84
+ [FAQ]: https://www.contributor-covenant.org/faq
85
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,85 @@
1
+ # 贡献者公约行为准则
2
+
3
+ [English](CODE_OF_CONDUCT.md)
4
+
5
+ ## 我们的承诺
6
+
7
+ 我们作为成员、贡献者和领导者,承诺让每个人参与我们社区的体验都不受骚扰,无论其年龄、体型、可见或不可见的残疾、族裔、性特征、性别认同和表达、经验水平、教育程度、社会经济地位、国籍、个人外貌、种族、种姓、肤色、宗教或性身份和性取向如何。
8
+
9
+ 我们承诺以有助于建设开放、友好、多元、包容和健康社区的方式行事和互动。
10
+
11
+ ## 我们的标准
12
+
13
+ 有助于为我们社区营造积极环境的行为示例包括:
14
+
15
+ * 对他人展现同理心和善意
16
+ * 尊重不同的意见、观点和经验
17
+ * 给予并得体地接受建设性反馈
18
+ * 承担责任,向受我们错误影响的人道歉,并从经历中学习
19
+ * 关注的不仅是对我们个人最有利的事,而是对整个社区最有利的事
20
+
21
+ 不可接受的行为示例包括:
22
+
23
+ * 使用带有性意味的语言或图像,以及任何形式的性关注或性挑逗
24
+ * 挑衅、侮辱或贬损性评论,以及人身或政治攻击
25
+ * 公开或私下的骚扰
26
+ * 未经他人明确许可,发布他人的私人信息,例如实际地址或电子邮件地址
27
+ * 其他在职业环境中可被合理视为不当的行为
28
+
29
+ ## 执行责任
30
+
31
+ 社区领导者负责阐明和执行我们的可接受行为标准,并会对任何他们认为不当、具有威胁性、冒犯性或有害的行为采取适当且公平的纠正措施。
32
+
33
+ 社区领导者有权并有责任删除、编辑或拒绝不符合本行为准则的评论、提交、代码、wiki 编辑、issue 和其他贡献,并在适当时说明管理决定的理由。
34
+
35
+ ## 适用范围
36
+
37
+ 本行为准则适用于所有社区空间,也适用于个人在公共空间正式代表社区的情形。代表社区的示例包括使用官方电子邮件地址、通过官方社交媒体账号发帖,或在线上或线下活动中担任指定代表。
38
+
39
+ ## 执行
40
+
41
+ 辱骂、骚扰或其他不可接受行为,可通过 [`SECURITY.zh.md`](SECURITY.zh.md) 所述的渠道,私下报告给负责执行的社区领导者:[GitHub 私有报告表单](https://github.com/Big-Dao/dsh-plugin-wsl-env/security/advisories/new);如果该表单对你不可用,也可以提交一个 issue,请维护者提供私下渠道,但不要在 issue 中描述事件。该渠道既用于行为报告,也用于漏洞报告;`SECURITY.md` 中关于报告应包含哪些内容的指引及其响应时间目标,是针对漏洞编写的,不适用于行为报告。所有投诉都会被及时、公平地审查和调查。
42
+
43
+ 所有社区领导者都有义务尊重任何事件报告者的隐私和安全。
44
+
45
+ ## 执行指南
46
+
47
+ 社区领导者在决定对任何他们认为违反本行为准则的行为采取何种后果时,将遵循以下社区影响指南:
48
+
49
+ ### 1. 纠正
50
+
51
+ **社区影响**:使用不当语言,或其他被视为不专业或不受社区欢迎的行为。
52
+
53
+ **后果**:由社区领导者发出私下书面警告,说明违规的性质,并解释该行为为何不当。可能会要求公开道歉。
54
+
55
+ ### 2. 警告
56
+
57
+ **社区影响**:通过单一事件或一系列行为构成的违规。
58
+
59
+ **后果**:发出警告,并说明若继续该行为将产生的后果。在指定期限内,不得与相关人员进行任何互动,包括主动与执行本行为准则的人员互动。这包括避免在社区空间以及社交媒体等外部渠道中的互动。违反这些条款可能导致临时或永久封禁。
60
+
61
+ ### 3. 临时封禁
62
+
63
+ **社区影响**:严重违反社区标准,包括持续的不当行为。
64
+
65
+ **后果**:在指定期限内,暂时禁止与社区进行任何形式的互动或公开交流。在此期间,不得与相关人员进行公开或私下互动,包括主动与执行本行为准则的人员互动。违反这些条款可能导致永久封禁。
66
+
67
+ ### 4. 永久封禁
68
+
69
+ **社区影响**:表现出违反社区标准的行为模式,包括持续的不当行为、对个人的骚扰,或对某类人群的攻击或贬损。
70
+
71
+ **后果**:永久禁止在社区内进行任何形式的公开互动。
72
+
73
+ ## 署名
74
+
75
+ 本行为准则改编自 [Contributor Covenant][homepage] 2.1 版,可从 [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1] 获取。
76
+
77
+ 社区影响指南受到 [Mozilla 的行为准则执行阶梯][Mozilla CoC] 的启发。
78
+
79
+ 关于本行为准则的常见问题解答,见 [https://www.contributor-covenant.org/faq][FAQ]。翻译版本见 [https://www.contributor-covenant.org/translations][translations]。
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
83
+ [Mozilla CoC]: https://github.com/mozilla/diversity
84
+ [FAQ]: https://www.contributor-covenant.org/faq
85
+ [translations]: https://www.contributor-covenant.org/translations
package/CONTRIBUTING.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Contributing
2
2
 
3
+ [中文](CONTRIBUTING.zh.md)
4
+
3
5
  This document covers the development loop, the gates a pull request must pass, and
4
6
  the conventions this repository uses.
5
7
 
@@ -189,6 +191,7 @@ terminal if you would rather not see the prompt.
189
191
  | `pnpm test` | style checks, relative links, requirement citations, doc consistency, syntax pass, build consistency, type check, and unit tests | no |
190
192
  | `pnpm run lint:links` | relative Markdown links in README, CONTRIBUTING, AGENTS and `docs/**` | no |
191
193
  | `pnpm run test:coverage` | unit tests with coverage, then the per-module gate: every `lib/*.js` measured or allowlisted, per-module floors 85/70/60 | no |
194
+ | `pnpm run test:browser` | the web client rendered in headless Chromium: layout, visibility, clicks, badge effect timing, panel list | no; `pnpm exec playwright install chromium` once |
192
195
  | `pnpm run lint:style` | style and lint rules | no |
193
196
  | `pnpm run lint:build` | the build-freshness check: every source has its artifacts and the committed bytes match a real build | no |
194
197
  | `pnpm run lint:types` | the TypeScript check over `test/**` and the ambient types (`tsc --noEmit`) | no |
@@ -218,7 +221,8 @@ Every script above is wired in `package.json`. `pnpm test` runs `lint:style`,
218
221
  release before the upload.
219
222
 
220
223
  CI runs `pnpm test` on Node 22 and 24, on both `ubuntu-latest` and
221
- `windows-latest`, and `pnpm run test:coverage` on Node 24. The Windows runners are
224
+ `windows-latest`, `pnpm run test:coverage` on Node 24, and `pnpm run test:browser`
225
+ on one Ubuntu runner after installing Chromium. The Windows runners are
222
226
  there because the plugin targets Windows; the coverage thresholds need Node 22.8 or
223
227
  newer, which is why that job runs on one version.
224
228
 
@@ -300,6 +304,18 @@ the argument builder out of `lib/bwrap.js`. A test that cannot run everywhere
300
304
  must skip itself — print a `SKIP` line and exit 0 — the way that file does on
301
305
  `win32`, where its fake `wsl.exe` (a POSIX script) cannot execute.
302
306
 
307
+ ### Browser E2E
308
+
309
+ `test/browser/e2e.test.mjs` bundles `client.js` with React and mounts the real
310
+ slot components in headless Chromium. It owns what the Node suite cannot see:
311
+ computed layout, visibility, real clicks, and effect timing across two mounted
312
+ components (the “收起” handoff from banner to header badge). It does not boot the
313
+ Desktop shell; a failure names the plugin's web bundle, not the host.
314
+
315
+ Run `pnpm exec playwright install chromium` once, then run the suite: `pnpm run test:browser`
316
+ The CI `browser` job does the same on `ubuntu-latest`; `pnpm test` stays
317
+ browser-free so a checkout without a browser still runs the ordinary gate.
318
+
303
319
  Probes are shell scripts, plus the small plugin files they load: the `*-probe.mjs`
304
320
  and `*-probe.yml` files in the same directory. Harness probes including `run.sh`,
305
321
  `terminal.sh`, `sandbox-shell.sh`, `interop-shell.sh`, `picker.sh`,
@@ -360,7 +376,7 @@ the tested environment and are not a substitute for rerunning the applicable gat
360
376
 
361
377
  The repository labels self-contained changes `good first issue`. Typical shapes:
362
378
 
363
- - a recipe or troubleshooting row in `README.md` or `docs/QUICKSTART.md`
379
+ - a recipe or troubleshooting row in the README pair or the QUICKSTART pair
364
380
  (the link check gates it; one commit);
365
381
  - a probe report fixture under `test/probe/` that follows an existing
366
382
  `*-report.txt` shape;
@@ -382,7 +398,7 @@ Windows + WSL machine; unit tests, docs and packaging changes do not.
382
398
  - Keep one topic per commit.
383
399
  - In the pull request, say how you tested it. Paste probe output where a probe is
384
400
  relevant.
385
- - Update `README.md` and `docs/README.zh.md` together when a change affects usage.
401
+ - Community-facing docs are bilingual; keep the English and Chinese pages section-for-section. The covered set is README, QUICKSTART, CONFIGURATION, LIMITATIONS, DIAGNOSTICS, COMPATIBILITY, PERFORMANCE, MIGRATION, API, ARCHITECTURE, CONTRIBUTING, SECURITY, SUPPORT, CODE_OF_CONDUCT and VALUE.
386
402
  The two files match section for section.
387
403
 
388
404
  ## Reporting bugs and security issues
@@ -0,0 +1,200 @@
1
+ # 贡献指南
2
+
3
+ [English](CONTRIBUTING.md)
4
+
5
+ 本文介绍开发循环、pull request 必须通过的检查,以及本仓库采用的约定。
6
+
7
+ ## 前置条件
8
+
9
+ | 需求 | 说明 |
10
+ |---|---|
11
+ | Windows 10 或 11 | 插件仅支持 Windows |
12
+ | 带至少一个发行版的 WSL2 | `wsl.exe -l -v` 列出已安装的发行版 |
13
+ | 发行版内有 `bubblewrap` | `sudo apt install bubblewrap`。缺少它时沙箱会失败关闭。 |
14
+ | Node 22.19+ 或 24 | CI 运行的版本。`engines` 要求 `^22.19.0 \|\| >=24.0.0`,即 harness 宿主自身的最低要求。 |
15
+
16
+ ## 工具链
17
+
18
+ 运行时包刻意不包含任何 `dependencies` 字段:它被加载进 DSH 进程,所需的一切都以 peer 包形式提供。从检出目录运行插件无需安装步骤。
19
+
20
+ 开发过程和运行各项检查则确实需要依赖。测试会 import 固定版本的 `@deepseek-ai/*` 包——组合测试运行 loader 的真实 patch 算法,启动测试通过真实的 Loader 启动一行——因此全新检出在检查通过前需要执行一次 `pnpm install`。
21
+
22
+ 这些固定版本是刻意为之,并按角色区分。`@deepseek-ai/*` 的 `devDependencies` 保持精确版本,使检查和 `docs/PEER-PARITY.md` 审计指向同一条可复现的版本线(工具链依赖——typescript、js-yaml、`@types/*`——使用版本范围并手动升级)。`peerDependencies` 是下限——`@deepseek-ai/dsh-*` 包用 `>=`,`@deepseek-ai/cordis` 和 `@deepseek-ai/schemastery` 用 caret——这样发布较新 harness 的应用无需等待插件发版就能继续安装插件。下限仍是有意抬高的,而不是随版本漂移:它在匹配某次 harness 发版的提交中上移,同时重新运行对拍比较和检查链;每周的 peer-canary(`.github/workflows/peer-canary.yml`)会把 `next` dist-tag 解析到临时树中,当版本线越过下限时发出告警。有一个 semver 限制值得了解:下限范围无法指定未来的预发布版本线——`0.2.2-rc.1` 不满足 `>=0.2.1-rc.3`,因为规范只允许预发布版本与自身 `[major, minor, patch]` 元组上的比较器匹配——因此全新的 rc 线在下限抬高前会告警;同一版本线上的 rc 和所有稳定版本从不会告警。
23
+
24
+ 插件继承 peer 类并镜像 peer 协议,因此版本范围并不能说明对拍声明是否成立:每次抬高下限都会重新验证这些声明。
25
+
26
+ 本仓库的脚本由 pnpm 运行,版本通过 `packageManager` 字段锁定(由 corepack 解析)。请把 `pnpm run <script>` 视为参考工具链。
27
+
28
+ 不要新增运行时依赖——理由见上。风格工具也因同样的理由不引入:这里没有 ESLint,也没有 Prettier。通常需要它们完成的检查改用 Node 内建能力实现。`test/style.mjs` 验证 `.editorconfig` 声明的规则,并检查每个 `files` 条目仍匹配受版本控制的内容、每个 `exports` 目标仍然存在。`pnpm test` 中的语法检查使用 Node 自身的解析器。
29
+
30
+ 恰好有三个依赖会运行安装脚本(`@deepseek-ai/dsh-subprocess-local`、`koffi`、`node-pty`——原生部分);它们被列入 `pnpm-workspace.yaml` 的允许列表,其余依赖不构建任何内容。
31
+
32
+ ## 类型检查
33
+
34
+ `lint:types` 在 `strict` 下运行 `tsc --noEmit`,用 `checkJs` 检查非生成的内容——`test/**` 与环境类型声明——类型来自 peer 包自带的 `.d.ts`:不会有任何类型被重复定义。`types/dsh-services.d.ts` 引入服务包随附的 `declare module '@deepseek-ai/cordis'` 增强,因此 `ctx.fs`、`ctx.shell`、`ctx.sandboxPolicy` 等都有类型;该文件自身不声明任何内容,也不会随包发布。
35
+
36
+ `test/probe/` 下的探针脚本也在检查范围内。`src/` 下的源码由构建程序本身检查(`strict`、`noEmitOnError`),这比检查它们生成的 JavaScript 严格得多。先检查已发布的产物,因为与固定 peer 的协议漂移会在那里造成实际损害;随后检查测试和探针,它们暴露的错误都是真实的——一个把原始数字固定进 argv 的测试,若干手写的 JSDoc 契约比代码更宽(`wslErrorCode`、`gitSpawnRewrite`)或比其接缝更窄,以及发行版路由文件服务中一个被接受但从未执行的字节窗口上限,发现它是因为某个 fake 向隔离接缝传入了 `"full"` enforcement,而核心自身从不报告该值。
37
+
38
+ 三种做法让检查保持诚实:
39
+
40
+ - 子类自己的 config 键声明为一个镜像其 `static Config` schema 的类型,并通过一次显式转换读取——这样 schema 与类型只可能以可见的方式发生偏移。
41
+ - 测试替身按其模拟的接缝切片(一个 duck `@typedef`)标注类型,并在注入点通过一次有注释的转换到达接缝声明的类型——该转换说明替身代表哪份契约,而不是用 `any` 压掉不匹配。
42
+ - 只有在被抑制的错误确实指向真实的上游接缝缺口、行内带有原因,并且该缺口已写成文档时,才允许使用 `@ts-expect-error`——当修复需要上游处理时,写在 `docs/UPSTREAM-*.md` 跟踪文档中(`LocalBashExecutor.spawnSpec` 接缝就有一份);当诚实修复需要本包做出协议决策时,写在源码注释本身。当前例外是 `spawnSpec` 接缝;它是一项已公开的发现,而不是消音器。
43
+
44
+ ## 构建
45
+
46
+ 插件必须能从裸检出目录加载:harness 没有转译层,Windows 运行时镜像是整棵树的副本,测试运行的是 `lib/*.js`——已发布的产物——而不是源码。源码位于 `src/`,构建出的 JavaScript 与声明位于 `lib/`,产物保持提交进仓。`pnpm run build`(`scripts/build.mjs`)执行一遍 `tsc -p tsconfig.build.json`,把每个 `src/*.ts` 生成为 JavaScript 及其声明,并使用与它所替代的手写模块相同的导出路径。import 指向产物(`./x.js`);`nodenext` 会通过 TypeScript 源码解析它。随后构建会清理没有源码归属的声明(重命名遗留),因此 `lib/` 恰好是 `src/` 的产物。
47
+
48
+ 让这一点保持诚实的规则:
49
+
50
+ - 绝不要编辑 `lib/` 下的生成文件——其模块文档会指明应编辑的源码,两者一旦偏移,`lint:build` 就会失败。生成产物保持 tsc 的规范格式(四空格缩进、紧凑格式);审查每个模块时看 `src/`。
51
+ - `lint:build`(`test/build-freshness.mjs`)强制文件集合闭合——每个 `lib/*.js` 都有对应的 `src/<name>.ts`,每个源码都有两个产物——然后为每个生成文件做快照,运行真实构建,逐字节比较并还原快照:这是一次检查,不是重建;偏移的补救办法是 `pnpm run build` 加一次提交。它位于 `test:syntax` 之后的检查链中。
52
+ - 生成文件完全不进入 `checkJs` 检查(`tsconfig.json` 覆盖 `test/**` 和环境类型声明);它们的源码由构建程序以 `noEmitOnError` 做类型检查,因此损坏的构建永远不会覆盖 `lib/`。
53
+ - 每个 JavaScript 导出都带有 `types` 条件(由 `lint:style` 强制),因此下游能解析这些声明;不存在第二套手写类型表面。
54
+ - 协议消息联合体及相关类型现在是唯一的定义处:使用方直接 import 它们(`@typedef {import("./agent-protocol.js").AgentMessage} AgentMessage`),而不是重新声明;`lib/agent.js` 和脚本驱动的测试就是这样读取它们。
55
+
56
+ ### 新增模块
57
+
58
+ 1. 编写 `src/<name>.ts`;import 指向产物(`./x.js`),`nodenext` 会通过 TypeScript 源码解析它。把所有类型移入签名,保留说明文字,并保留每一个导出的名称——包括类型,因为使用方会 import 它们(`import("./paths.js").DistroPath`)。在模块文档末尾写上说明,指明生成的产物。
59
+ 2. 运行 `pnpm run build`,再运行 `pnpm test`。无需维护排除列表,也没有注册步骤:构建和 `lint:build` 从 `src/` 推导一切,`lib/` 是生成输出——绝不要手工编辑。
60
+ 3. 如果模块在 Plugins 页面拥有自己的一行,把它的显示元数据添加为 `locale/<name>/en.json` 和 `locale/<name>/zh.json`——各含一对 `meta.title` / `meta.description`——并通过 `exports` 暴露两者(`./<name>/locale/en.json`、`./<name>/locale/zh.json`),该页面会先读取它们,再回退到包的 `description`。bundle 自己的那一对是 `locale/en.json` / `locale/zh.json`,`subprocess`、`picker`、`shell-env` 和 `auto-preset` 各自带有自己的那一对。有一组运行时 catalog 不是 `exports` 条目:`locale/doctor/*.json` 为独立 CLI 的固定骨架提供本地化,由脚本自身从包根目录读取。`files` 已随包发布 `locale/**/*.json`,而 `lint:style` 会让不存在的 `exports` 目标失败。
61
+
62
+ ## 开发循环
63
+
64
+ 1. 在发行版内克隆仓库。多数贡献者在那里开发。
65
+ 2. 修改代码。
66
+ 3. 运行下面的检查。
67
+ 4. 如果改动了 `lib/` 下的任何内容,先运行 `pnpm run sync:windows`,再重启 DSH 应用。应用加载 Windows 镜像(见下文),因此不同步就重启只会重新加载旧代码;运行中的进程还会缓存 ES 模块。
68
+
69
+ ### 运行时镜像
70
+
71
+ DSH profile 只能链接 Windows 路径。pnpm 会把 `link:\\wsl.localhost\...` 重写成损坏的 `/wsl.localhost/...` 符号链接,因此 harness 无法从发行版检出目录加载插件。
72
+
73
+ `default-workspace/dsh-plugin-wsl` 下的 Windows 副本是运行时镜像。启动应用前先同步它:
74
+
75
+ ```bash
76
+ pnpm run sync:windows
77
+ ```
78
+
79
+ 镜像目标位于会话工作区之外。在受限 shell 中运行同步的 agent 会被 `workspace-write` 策略拒绝,必须为这一条命令批准更宽的权限。如果不想看到该提示,请从普通发行版终端运行同步。
80
+
81
+ ## pull request 前的检查
82
+
83
+ | 命令 | 覆盖范围 | 需要 harness |
84
+ |---|---|---|
85
+ | `pnpm test` | 风格检查、相对链接、需求引用、文档一致性、语法检查、构建一致性、类型检查和单元测试 | 否 |
86
+ | `pnpm run lint:links` | README、CONTRIBUTING、AGENTS 和 `docs/**` 中的相对 Markdown 链接 | 否 |
87
+ | `pnpm run test:coverage` | 带覆盖率的单元测试,然后逐模块检查:每个 `lib/*.js` 都被测量或列入允许列表,逐模块下限 85/70/60 | 否 |
88
+ | `pnpm run test:browser` | 在无头 Chromium 中渲染的 web 客户端:布局、可见性、点击、badge 效果时序、面板列表 | 否;需先执行一次 `pnpm exec playwright install chromium` |
89
+ | `pnpm run lint:style` | 风格与 lint 规则 | 否 |
90
+ | `pnpm run lint:build` | 构建新鲜度检查:每个源码都有产物,且提交的字节匹配真实构建 | 否 |
91
+ | `pnpm run lint:types` | 对 `test/**` 和环境类型声明的 TypeScript 检查(`tsc --noEmit`) | 否 |
92
+ | `pnpm run e2e:install` | 在临时 `DSH_HOME` 中安装/升级/卸载打包 tarball | 是;Windows + WSL |
93
+ | `pnpm run doctor` | 环境前置项、peer 和缓存(脚本使用 `--json`;`diagnose` 是只读别名) | 否;在发行版内 |
94
+ | `pnpm run probe` | 针对真实发行版的文件系统行为 | 是 |
95
+ | `pnpm run probe:sandbox` | bubblewrap 隔离了什么、没有隔离什么 | 否 |
96
+ | `pnpm run probe:sandbox-shell` | 通过真实启动验证受限执行器 | 是 |
97
+ | `pnpm run probe:interop-shell` | 对盘符可执行文件和复制出的可执行文件进行驻留式与一次性互操作,含/不含 `/mnt` 掩码 | 是 |
98
+ | `pnpm run probe:terminal` | 终端 provider | 是 |
99
+ | `pnpm run probe:substrate` | 通过真实 `wsl.exe` 传输验证 agent 文件系统 substrate | 否;在发行版内 |
100
+ | `pnpm run probe:watch` | 针对真实目录的发行版内 watcher | 否;在发行版内 |
101
+ | `pnpm run probe:agent` | 驻留式与一次性回退的对拍分支 | 否;在发行版内 |
102
+ | `pnpm run probe:exec` | agent 支撑的执行句柄:超时、kill、cwd 失败 | 否;在发行版内 |
103
+ | `pnpm run probe:missing-wsl` | 无法启动的 `wslPath` 如何报告 | 是 |
104
+ | `pnpm run probe:picker` | 选择器的根层级、拒绝行为和上限 | 是 |
105
+ | `pnpm run probe:gui-preview` | 路由后端的 stat、列表与 1 MiB 页读取延迟(p50/p95 预算) | 否;在发行版内 |
106
+ | `pnpm run probe:file-reference` | `@` 引用遍历:9p 遍历 vs 发行版的 ext4 | 否;在发行版内 |
107
+ | `pnpm run probe:fs-routing` | 根平面路由器:发行版坐标、宿主平面、跨发行版围栏 | 是 |
108
+ | `pnpm run probe:mode` | 哪些 POSIX 模式事实能在共享中保留 | 否;Windows Node |
109
+ | `pnpm run probe:sandbox-off` | 两个 provider 上文档说明的退出选项 | 是 |
110
+
111
+ 上述每个脚本都在 `package.json` 中定义。`pnpm test` 按顺序运行 `lint:style`、`lint:links`、`lint:requirements`、`lint:docs`、`test:syntax`、`lint:build`、`lint:types` 和 `test:unit`。`prepublishOnly` 在发布时再次运行 `pnpm test`,因此损坏的检查会在上传前阻止发布。
112
+
113
+ CI 在 `ubuntu-latest` 和 `windows-latest` 上,用 Node 22 和 24 运行 `pnpm test`;在 Node 24 上运行 `pnpm run test:coverage`,并在安装 Chromium 后于一个 Ubuntu runner 上运行 `pnpm run test:browser`。Windows runner 的存在是因为插件面向 Windows;覆盖率门槛需要 Node 22.8 或更新版本,因此该任务只在一个版本上运行。
114
+
115
+ 标记为“是”的探针需要 Windows、WSL2、一个已挂载的 harness profile 和一个已链接的检出,托管 runner 不具备这些条件。请在自己的机器上运行,并把输出粘贴到 pull request 中。
116
+
117
+ 标记为“否;在发行版内”的行(`substrate`、`watch`、`agent`、`exec`)仍需要 Windows 和 WSL2,但不需要启动 harness,也不需要 profile:在有 Node 的发行版终端中运行它们,它们会通过互操作访问 `wsl.exe`。
118
+
119
+ 真机测试集有两个便利工具。`test/probe/run-all-when-closed.sh --include-fs` 在应用退出后运行全部十七项探针。互操作 shell 矩阵使用 `wslfs` profile、systemd 和 lingering 的用户管理器;当 Windows 互操作或其临时标记无法验证时,它会失败。`ci.yml` 有一个定时和手动触发的 `probes` 任务:只要默认发行版实际启动,`sandbox` 就会运行;随后在安装了 harness 应用的环境中运行 `mode`、`terminal`、`picker` 和 `missing-wsl`。该任务以一个自托管 Windows runner 命名,尽管其 `runs-on` 携带的是 GitHub 托管的 `windows-latest` 标签;当托管 runner 没有可用的发行版时,该任务是一次绿色的空操作(`skip all`)。如果默认发行版启动时没有 bubblewrap,`sandbox` 分支会失败,而不是跳过。
120
+
121
+ **自托管 runner 标签冲突——已知暴露面。** 开发机的自托管 runner 满足了 GitHub 托管的 `windows-latest` 标签,因此单元矩阵的 Windows 分支在每次 push 和 PR 时都在那里执行。来自 fork 的 PR 代码会在这些分支上被跳过(`ci.yml` 的步骤级 fork 门),但持久的修复是在 runner 设置中把其标签重命名为无歧义的名称(例如 `self-hosted-wsl`),并把 `ci.yml` 中两个 `windows-latest` 使用方重新指向它——在此之前,请把该标签视为共享基础设施,而不是托管容量。还要注意安装步骤带有 `--config.minimum-release-age=0`(pnpm 11.7 的 lockfile 重新验证会忽略 `minimumReleaseAgeExclude`;该标志是 `release.yml` 中记录的补救办法)。
122
+
123
+ ## 新增测试
124
+
125
+ 按测试所需选择层次。
126
+
127
+ | 层次 | 位置 | 用于 |
128
+ |---|---|---|
129
+ | 单元测试 | `test/*.test.mjs` | 纯逻辑:路径转换、列表、shell 参数构建、终端辅助函数 |
130
+ | 探针 | `test/probe/` | 需要真实发行版、真实 profile 或 bubblewrap 的行为 |
131
+
132
+ 单元测试在 `node --test` 下运行。`package.json` 中的 `test:unit` 和 `test:coverage` 列表显式列出各自的文件;只涉及本仓库的测试应同时出现在两者中。保持两个列表同步且没有重复条目。
133
+
134
+ 两个脚本都在 `scripts/test-watchdog.mjs` 下运行各自的列表,该 watchdog 把整次运行限制在 180 秒内(可用 `DSH_TEST_WATCHDOG_MS` 覆盖)。`node --test` 没有逐文件截止时间,因此一个脚本式文件如果在尚未完成的顶层 await 背后留下活动句柄,就会让检查挂起,直到调用方杀掉它;到达截止时间时,包装器会中断运行,node 的 “Interrupted while running” 列表会指出从未完成的文件。脚本还会传入 `--test-timeout=60000`,它只限制文件用 `test()` 注册的测试——watchdog 才覆盖模块求值阶段的挂起。
135
+
136
+ `test:coverage` 还会通过 `scripts/coverage-gate.mjs` 运行该列表。Node 的覆盖率基于加载——没有测试 import 的模块不会有一行记录,因此全局百分比会静默地只衡量一个子集——所以该检查要求每个 `lib/*.js` 都被测量,或在 `test/coverage-allowlist.json` 中列出并说明为何无法被受检查的测试套件加载;每个被测量的模块都要满足 85 行 / 70 分支 / 60 函数的下限。没有测试的新模块会让检查失败,已不存在模块的允许列表条目同样如此。新增测试是首选修复;允许列表让其余仅由探针覆盖的行保持可见,而不是让它们从分母中消失。
137
+
138
+ import 固定版本 `@deepseek-ai/*` 包的测试也进入同样的列表,无需额外防护——CI 在 `pnpm test` 之前对锁定树运行 `pnpm install --frozen-lockfile`。例如,`test/provider.test.mjs` 覆盖装配后的服务行,`test/composition.test.mjs` 运行 loader 的真实 patch 算法。
139
+
140
+ 凡是存在无 peer 的接缝,优先使用它。`test/sandbox.test.mjs` 针对 `lib/sandbox-core.js` 运行,并用一个替身代替 peer 的 `SandboxUnavailableError` 契约,这样 `lib/sandbox.js` 中只剩一行 peer 绑定。那一行由 harness 探针覆盖——它们启动插件,从而通过 `lib/index.js` 到达 `WslSandbox`——而不是由 `probe:sandbox` 覆盖,后者只从 `lib/bwrap.js` 读取参数构建器。无法在所有环境运行的测试必须自行跳过——打印一行 `SKIP` 并以 0 退出——就像该文件在 `win32` 上的做法,在那里它的 fake `wsl.exe`(一个 POSIX 脚本)无法执行。
141
+
142
+ ### 浏览器 E2E
143
+
144
+ `test/browser/e2e.test.mjs` 用 React 打包 `client.js`,并在无头 Chromium 中挂载真实的 slot 组件。它负责 Node 测试套件看不到的内容:计算后的布局、可见性、真实点击,以及跨两个已挂载组件的效果时序(从 banner 到 header badge 的“收起”交接)。它不启动 Desktop shell;失败指向插件的 web bundle,而不是宿主。
145
+
146
+ 先运行一次 `pnpm exec playwright install chromium`,再运行测试套件:`pnpm run test:browser`。CI 的 `browser` 任务在 `ubuntu-latest` 上做同样的事;`pnpm test` 不依赖浏览器,因此没有浏览器的检出仍能运行常规检查。
147
+
148
+ 探针是 shell 脚本,外加它们加载的小型插件文件:同目录下的 `*-probe.mjs` 和 `*-probe.yml`。harness 探针包括 `run.sh`、`terminal.sh`、`sandbox-shell.sh`、`interop-shell.sh`、`picker.sh`、`fs-routing.sh`、`missing-wsl.sh` 和 `sandbox-off.sh`,它们使用一次性 profile,其设置记录在 `test/probe/run.sh` 的文件头中。发行版探针(`substrate.sh`、`watch.sh`、`agent.sh`、`exec.sh`)不启动 harness:它们从发行版终端运行,并通过 `wsl.exe` 互操作传输驱动驻留 agent。`sandbox.sh` 和 `mode.sh` 既不需要启动 harness,也不需要 profile。
149
+
150
+ 保持探针输出幂等。若干探针会在开始时删除自己的临时文件,因为早先运行遗留的文件会改变结果。
151
+
152
+ ## 已验证的内容
153
+
154
+ 在上面那一次 `pnpm install` 获取固定包之后,`pnpm test` 会运行整个单元测试套件:静态 import 这些包的文件会通过 loader 及其声明类型实际运行服务,`test:syntax` 对每个随包模块执行一遍 `node --check`。Linux 分支上的任何测试都无法触及 Windows + WSL2 拓扑本身:真实的 `wsl.exe`、真实的发行版、真实的 harness 启动。这正是探针填补的缺口;归档记录 §15.4 记录了它曾导致的五轮误诊。
155
+
156
+ `test/probe/sandbox.sh` 不需要 harness:它使用 `lib/sandbox.js` 构建的相同参数,断言 bubblewrap 隔离了什么、没有隔离什么,并把互操作逃逸记为 `INFO`,因为 Linux 沙箱无法管辖 Windows 进程。harness 探针启动一个绑定到该发行版的一次性 profile:
157
+
158
+ - 文件系统探针断言写入路径和写入检查——在策略根之外写入以及在 `read-only` 模式下写入都返回 `FS_SANDBOX_DENIED`,而 `danger-full-access` 是获准的升级方式,其写入被断言确实落地;
159
+ - shell 探针通过 `ctx.shell` 驱动全部三种模式,并检查工具层返回的拒绝分类;
160
+ - 终端探针断言发行版、起始目录,以及通过 `WSLENV` 转发的 `DSH_*` 变量。
161
+
162
+ 该一次性 profile 的设置步骤位于 `test/probe/run.sh` 的文件头;harness 探针共享它创建的那一个 profile。
163
+
164
+ 在 Windows 11 + WSL2(Ubuntu 26.04)上已验证以下内容:
165
+
166
+ - 各服务的接线、UNC 路径处理和选择器行为;
167
+ - 插件在真实 profile 中端到端挂载;
168
+ - 仅 WSL 的无头 profile 中一次真实的模型回合:`write → chmod → read → edit → execute`,可执行位在编辑后保留;
169
+ - 在一次性 Web 启动和日常 GUI profile 中的终端 provider;
170
+ - 沙箱的四种方式:在发行版内测量参数、文件系统写入检查、shell 路径(`enforcement: partial`,拒绝分类正确),以及日常 GUI profile——在那里,agent 自身会话在会话工作区之外的写入会在发行版内被拒绝,随后更宽权限的请求成功。
171
+
172
+ 当前的单元测试和覆盖率测试列表在 `package.json` 中;探针断言和前置条件在各脚本中。验证结果描述的是已测试的环境,不能替代重新运行适用的检查。
173
+
174
+ ## Good first issue 与贡献者路径
175
+
176
+ 仓库会用 `good first issue` 标记自包含的改动。典型形式:
177
+
178
+ - 在 README 与 QUICKSTART 的中英两侧添加一条配方或排障条目(链接检查会守护它;一次提交);
179
+ - 在 `test/probe/` 下新增遵循现有 `*-report.txt` 形式的探针报告夹具;
180
+ - 修复 issue 模板措辞、交叉引用,或补上 `docs/ARCHITECTURE.md` 中缺失的错误码行。
181
+
182
+ 要认领一个 issue,请在 issue 下评论。打开 PR 前运行 `pnpm test`(若改动 `lib/`,再运行 `pnpm run test:coverage`),然后做一次逻辑提交,并在提交正文中记录检查结果——约定见下文。探针需要真实的 Windows + WSL 机器;单元测试、文档和打包改动不需要。
183
+
184
+ ## 提交与 pull request 约定
185
+
186
+ - 使用祈使句主题行:`Fix the npm readme`,而不是 `Fixed` 或 `Fixes`。
187
+ - 不要使用 conventional-commit 前缀。不要写 `feat:`、`fix:` 或 `chore:`。
188
+ - 在正文中解释原因。改了什么在 diff 中已经可见。
189
+ - 行为变更需在 `## [Unreleased]` 下添加 `CHANGELOG.md` 条目。文档或注释改动不需要。
190
+ - 一次提交只包含一个主题。
191
+ - 在 pull request 中说明你如何测试。相关时粘贴探针输出。
192
+ - 社区常用文档成对存在;英文与中文两侧逐节对应。范围包括 README、QUICKSTART、CONFIGURATION、LIMITATIONS、DIAGNOSTICS、COMPATIBILITY、PERFORMANCE、MIGRATION、API、ARCHITECTURE、CONTRIBUTING、SECURITY、SUPPORT、CODE_OF_CONDUCT、VALUE。
193
+
194
+ ## 报告缺陷与安全问题
195
+
196
+ 缺陷请开 GitHub issue:
197
+
198
+ https://github.com/Big-Dao/dsh-plugin-wsl-env/issues
199
+
200
+ 安全问题请私下报告。请遵循 [SECURITY.zh.md](SECURITY.zh.md),不要开公开 issue。