dsh-team-bots 0.0.0-stage → 0.2.289

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 (143) hide show
  1. package/CONTRIBUTING.md +20 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +14 -0
  4. package/README.md +173 -2
  5. package/cordis.patch.yml +3 -0
  6. package/docs/README.zh.md +174 -0
  7. package/docs/assets/global-config-dark.png +0 -0
  8. package/docs/assets/global-config-light.png +0 -0
  9. package/docs/assets/tasks.png +0 -0
  10. package/docs/assets/usage-dark.png +0 -0
  11. package/docs/assets/usage.png +0 -0
  12. package/index.js +41 -0
  13. package/package.json +56 -4
  14. package/scripts/doctor.mjs +125 -0
  15. package/src/api.js +249 -0
  16. package/src/botmsg.js +126 -0
  17. package/src/config.js +255 -0
  18. package/src/db-migrations.js +302 -0
  19. package/src/db.js +544 -0
  20. package/src/errors.js +18 -0
  21. package/src/http.js +331 -0
  22. package/src/paths.js +131 -0
  23. package/src/pricing.js +129 -0
  24. package/src/project-skills.js +118 -0
  25. package/src/runtime.js +48 -0
  26. package/src/secrets.js +242 -0
  27. package/src/seed-bots.js +124 -0
  28. package/src/service.js +106 -0
  29. package/src/services/approvals.js +253 -0
  30. package/src/services/attention-schema.js +60 -0
  31. package/src/services/backoff.js +92 -0
  32. package/src/services/bots.js +311 -0
  33. package/src/services/chat.js +434 -0
  34. package/src/services/core.js +287 -0
  35. package/src/services/file-policy.js +43 -0
  36. package/src/services/hygiene.js +164 -0
  37. package/src/services/locale.js +113 -0
  38. package/src/services/memory.js +435 -0
  39. package/src/services/message-images.js +251 -0
  40. package/src/services/mixin.js +9 -0
  41. package/src/services/model-fallback.js +122 -0
  42. package/src/services/projects.js +552 -0
  43. package/src/services/proposals.js +308 -0
  44. package/src/services/questions.js +322 -0
  45. package/src/services/recovery-schema.js +32 -0
  46. package/src/services/review-watchdog.js +68 -0
  47. package/src/services/rollover-schema.js +26 -0
  48. package/src/services/run-finish.js +415 -0
  49. package/src/services/runs.js +638 -0
  50. package/src/services/runtime/lifecycle.js +365 -0
  51. package/src/services/runtime/model-restore.js +275 -0
  52. package/src/services/runtime/prompt.js +652 -0
  53. package/src/services/runtime/session.js +431 -0
  54. package/src/services/runtime/trajectory.js +135 -0
  55. package/src/services/scheduler.js +619 -0
  56. package/src/services/secrets.js +339 -0
  57. package/src/services/system.js +426 -0
  58. package/src/services/task-notify.js +77 -0
  59. package/src/services/task-relations.js +176 -0
  60. package/src/services/task-review.js +149 -0
  61. package/src/services/task-sandbox-schema.js +32 -0
  62. package/src/services/task-stage.js +54 -0
  63. package/src/services/tasks.js +772 -0
  64. package/src/services/terminal.js +176 -0
  65. package/src/services/usage.js +100 -0
  66. package/src/services/vision-proxy.js +196 -0
  67. package/src/services/wechat.js +98 -0
  68. package/src/services/workspace-groups.js +102 -0
  69. package/src/services/write-scopes.js +122 -0
  70. package/src/skill-parse.js +33 -0
  71. package/src/skills.js +302 -0
  72. package/src/tools.js +188 -0
  73. package/src/updater.js +109 -0
  74. package/src/usage-reconcile.js +269 -0
  75. package/src/usage.js +692 -0
  76. package/src/util.js +112 -0
  77. package/src/wechat/channel.js +506 -0
  78. package/src/wechat/commands.js +149 -0
  79. package/src/wechat/store.js +215 -0
  80. package/ui/app.js +794 -0
  81. package/ui/fonts/OFL.txt +92 -0
  82. package/ui/fonts/inter-400.woff2 +0 -0
  83. package/ui/fonts/inter-500.woff2 +0 -0
  84. package/ui/fonts/inter-600.woff2 +0 -0
  85. package/ui/i18n/en.js +239 -0
  86. package/ui/i18n/zh.js +238 -0
  87. package/ui/index.html +27 -0
  88. package/ui/modules/api.js +116 -0
  89. package/ui/modules/cards.js +509 -0
  90. package/ui/modules/chat.js +462 -0
  91. package/ui/modules/composer.js +667 -0
  92. package/ui/modules/events-board.js +273 -0
  93. package/ui/modules/events-click.js +613 -0
  94. package/ui/modules/events-misc.js +306 -0
  95. package/ui/modules/events-submit.js +256 -0
  96. package/ui/modules/global-pages.js +146 -0
  97. package/ui/modules/i18n.js +54 -0
  98. package/ui/modules/icons.js +43 -0
  99. package/ui/modules/markdown.js +116 -0
  100. package/ui/modules/modal-forms.js +798 -0
  101. package/ui/modules/modal-layer.js +175 -0
  102. package/ui/modules/settings.js +434 -0
  103. package/ui/modules/solo-archive.js +17 -0
  104. package/ui/modules/state.js +146 -0
  105. package/ui/modules/tasks.js +781 -0
  106. package/ui/modules/typing-linger.js +273 -0
  107. package/ui/modules/usage.js +386 -0
  108. package/ui/modules/util.js +174 -0
  109. package/ui/styles/a11y.css +37 -0
  110. package/ui/styles/avatars.css +54 -0
  111. package/ui/styles/base.css +326 -0
  112. package/ui/styles/boot.css +46 -0
  113. package/ui/styles/buttons.css +194 -0
  114. package/ui/styles/cards.css +282 -0
  115. package/ui/styles/chat-cards.css +439 -0
  116. package/ui/styles/chat-composer.css +245 -0
  117. package/ui/styles/chat-images.css +705 -0
  118. package/ui/styles/chat.css +370 -0
  119. package/ui/styles/frame.css +347 -0
  120. package/ui/styles/global-config.css +202 -0
  121. package/ui/styles/main.css +142 -0
  122. package/ui/styles/modal.css +288 -0
  123. package/ui/styles/settings.css +233 -0
  124. package/ui/styles/surfaces.css +106 -0
  125. package/ui/styles/tasks.css +580 -0
  126. package/ui/styles/terminal.css +398 -0
  127. package/ui/styles/toast.css +40 -0
  128. package/ui/styles/usage.css +367 -0
  129. package/ui/styles/wide.css +501 -0
  130. package/vendor/dompurify/LICENSE +568 -0
  131. package/vendor/dompurify/NOTICE +6 -0
  132. package/vendor/dompurify/package.json +171 -0
  133. package/vendor/dompurify/purify.min.js +3 -0
  134. package/vendor/marked/LICENSE +44 -0
  135. package/vendor/marked/NOTICE +5 -0
  136. package/vendor/marked/marked.umd.js +2604 -0
  137. package/vendor/marked/package.json +111 -0
  138. package/vendor/qrcode/NOTICE +5 -0
  139. package/vendor/qrcode/package.json +30 -0
  140. package/vendor/qrcode/qrcode.js +2298 -0
  141. package/vendor/wechat-ilink/LICENSE.tencent-openclaw-weixin +26 -0
  142. package/vendor/wechat-ilink/NOTICE +12 -0
  143. package/vendor/wechat-ilink/index.js +1383 -0
@@ -0,0 +1,20 @@
1
+ # Contributing
2
+
3
+ ## Commit conventions
4
+
5
+ - Every commit has the pre-commit hook bump the patch digit of `package.json` by one (`DSH_SKIP_VERSION_BUMP=1` skips it). **Take the committed version from `git show HEAD -- package.json`**, not from the file in the working tree.
6
+ - Commit messages use Conventional Commits style and carry the card number, e.g. `feat(ui): 全局配置页美术重设计(DSHBOTS-184)`.
7
+ - Commit with an exact pathspec (`git commit -- <pathspec>`), and check `git status --short` before and after, so in-flight work from other sessions never gets swept in.
8
+
9
+ ## Guard tests
10
+
11
+ `tests/` holds one `*.test.js` per feature domain, plus the pins for several architectural conventions:
12
+
13
+ - `tests/styles-split.test.js`: `UI_STYLE_PARTS` corresponds one-to-one with the `ui/styles/` directory (no orphans, no missing entries, no duplicates), each file stays under 800 lines, and the concatenation has zero drift.
14
+ - `tests/code-hygiene.test.js`: the line-limit semantics (800 by default, judgement line at limit × 110 %, 0 disables it, one alert per violation, a fresh alert after the file falls back under the limit).
15
+ - Cross-slice `import` guards and token-format guards cover the whole `ui/` source tree: a missing import after a slice split leaves the page on the boot screen, so this class of failure is caught in advance.
16
+
17
+ ## `ui/` contribution rules
18
+
19
+ 1. **Style slices must be registered.** The concatenation order is decided by `UI_STYLE_PARTS` in `src/http.js`, so a new style file must be registered there too; `tests/styles-split.test.js` guards the table's completeness.
20
+ 2. **The 800-line rule.** Both `ui/styles/*.css` and `ui/app.js` stay under 800 lines per file; beyond that, split by responsibility into new domain files.
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 [yyyy] [name of copyright owner]
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/NOTICE ADDED
@@ -0,0 +1,14 @@
1
+ DSH Team Bots
2
+ Copyright 2026 DSH Team Bots contributors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Architecture and DSH integration were informed by:
7
+ - DS Bot, Copyright 2026 Fei2411 and the DS Bot contributors, Apache-2.0
8
+ https://github.com/Fei2411/DS-Bot
9
+ - Cindy, Copyright Cindy contributors, Apache-2.0
10
+ https://github.com/makecindy/cindy
11
+
12
+ Runtime dependency:
13
+ - DeepSeek Harness (DSH), Copyright (c) 2026 DeepSeek, MIT License
14
+ https://github.com/deepseek-ai/deepseek-harness
package/README.md CHANGED
@@ -1,3 +1,174 @@
1
- # Temporary Holding Version
1
+ # DSH Team Bots
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [中文](docs/README.zh.md)
4
+
5
+ DSH Team Bots is the npm package `dsh-team-bots`, a DSH (DeepSeek Harness) plugin that packs a collaborating crew of bots into one workspace: project group chats, a task board, write-scope parallel scheduling, memory and skills, usage and cost, plus a personal WeChat channel.
6
+
7
+ ![DSH Team Bots workspace](docs/assets/tasks.png)
8
+
9
+ This file is the English edition of the project documentation; the Chinese edition is [docs/README.zh.md](docs/README.zh.md).
10
+
11
+ ---
12
+
13
+ ## 1. Project Overview
14
+
15
+ `dsh-team-bots` runs inside the DSH Web process — no separate service — and lets several bots divide work across the same project spaces, exposing the collaboration as an operable web workspace.
16
+
17
+ 1. **Collaboration happens in projects, not in a chat window.** Each project has its own group chat, members, tasks and working directory; the project director bot splits, assigns and accepts work there.
18
+ 2. **Parallelism is declared, not hoped for.** A task declares the paths it will write; the scheduler runs two write runs in the same project in parallel only when both declare and their path prefixes do not overlap. Anything undeclared is treated as serial.
19
+ 3. **Everything is traceable.** Every run keeps a trajectory, duration, token count and cost; bot configuration keeps an immutable history that can be rolled back; secrets stay encrypted at rest and are materialised as one-time plaintext files that are burned after use.
20
+
21
+ The repository shape: `index.js` is the plugin entry point, `src/` is the server side and scheduler, `ui/` is the workspace frontend, `tests/` holds the guard tests, and `docs/` holds design specs, review records and screenshots.
22
+
23
+ ---
24
+
25
+ ## 2. Quick Start
26
+
27
+ ### 2.1 Requirements and install
28
+
29
+ Node.js ≥ 22.19 (see `engines` in `package.json`) and the DSH CLI installed (`dsh --version`); the plugin runs inside the DSH Web process, with no standalone process or port.
30
+
31
+ ```sh
32
+ cd <repo>
33
+ npm pack # produces dsh-team-bots-<version>.tgz
34
+ dsh plugin --profile <name> add ./dsh-team-bots-<version>.tgz
35
+ dsh --profile <name> # read the tokenised dsh web entry from the startup log
36
+ ```
37
+
38
+ ### 2.2 Reinstall and local preview
39
+
40
+ ```sh
41
+ npm run profile:install -- --profile <name> # installs into team-bots when --profile is omitted
42
+ npm run dev # local preview at http://127.0.0.1:4317, fake runtime
43
+ ```
44
+
45
+ `profile:install` packs the repository and reinstalls the plugin into a profile. **Plugin files inside a profile are a snapshot and DSH does not pick up replaced files on its own**: after changing code you must reinstall, or the page sticks at "connecting to the team space". Team data is decoupled from the profile: `DSH_TEAM_WORKSPACE` / `DSH_TEAM_DATA` alone decide the data directory. The preview server uses a fake DSH runtime — **no authentication, no DSH configuration touched, not for production**; override the port with `PORT`.
46
+
47
+ ### 2.3 Data, secrets and skills
48
+
49
+ Data lives under `DSH_TEAM_DATA` (default `<workspace>/.data`, workspace root `DSH_TEAM_WORKSPACE`, default `~/.dsh/workspace/team-bots`): `team.sqlite`, `wechat-channel.sqlite`, `secret.key`, `memory/`, `messages/` and `secrets-runtime/` (burned on TTL expiry). Back up `secret.key` together with the data — without it the existing ciphertext cannot be decrypted. Schema changes go through the idempotent migrations in `src/db-migrations.js`. Skills come from a shared pool fixed at `~/.agents/skills`, plus project-local `<project>/.agents/skills`, `<project>/.claude/skills` and `<project>/.codex/skills`.
50
+
51
+ A template for the common variables lives in `.env.example`; **do not put a `.env` file in the repository root**, because that would leak `DSH_*` into `npm test` and `npm run dev`.
52
+
53
+ ### 2.4 Entry points and environment variables
54
+
55
+ ```text
56
+ http://<host>:<port>/ auto-login, straight into the team workspace
57
+ http://<host>:<port>/api/dsh-team/ui the DSH Team Bots workspace (direct)
58
+ http://<host>:<port>/index.html the native DSH web UI
59
+ ```
60
+
61
+ The first visit to the home page exchanges the current startup token for a 30-day login cookie. Auto-login means **anyone who can reach the port becomes owner**, so listen on the local machine or a trusted network; public exposure needs an HTTPS reverse proxy that forwards Host and WebSocket correctly.
62
+
63
+ The two paths that matter are `DSH_TEAM_WORKSPACE` (team workspace root) and `DSH_TEAM_DATA` (team database and run records); every other variable, its default and its resolution order (explicit env > value saved on the page > code default) live in `src/config.js`.
64
+
65
+ ---
66
+
67
+ ## 3. Feature Overview
68
+
69
+ - **Project group chat:** every project has one group chat and one director bot. Plain messages, `@Bot`, `/task @Bot <title>`, `/remember` and `/clear` are supported, with `/` and `@` completions for commands, skills and members. Conclusions stay in the chat; full deliveries go to task comments.
70
+ - **Task board:** a Linear-style panel grouped by status, with a parent/child tree, priority and assignee, comments delivered into running sessions, drag-to-transition, and inline delivery artefacts and run list.
71
+ - **Write-scope parallel scheduling:** declared write scopes decide whether two write runs in one project may run at once; write runs are independent, and neither tasks nor chats block one another.
72
+ - **Memory and skill pool:** bot- and project-level long-term memory with a human review queue; the shared skill pool is fixed at `~/.agents/skills` and projects can add their own skill directories; skill changes go through proposal approval with rollback snapshots.
73
+ - **Versioned evolution and team tools:** role, model, intensity and skill changes go through proposal approval, and bot configuration keeps an immutable, rollback-able history. The plugin registers the team tools for task assignment, review, memory, recall, evolution proposals, direct bot messaging and secret requests.
74
+ - **Secret pipeline:** AES-256-GCM at rest; once approved, materialised into the data directory (**not the project workspace**) and burned when the run ends or the TTL expires; messages and run output are always masked as `$<name>`.
75
+ - **Usage and cost:** tokens, call counts, cost and runtime aggregated at global, project and bot level; cost comes from configurable model prices and calls without a price are not billed as zero; CSV export and monthly reconciliation are available.
76
+ - **Approvals, questions and terminal:** privilege or human-answer requests become workspace cards — approvals time out to `rejected`, an expired question stays answerable. Each project has an interactive terminal with a hard timeout, live tailing, cancellation and persisted history.
77
+ - **WeChat channel and code hygiene:** QR-authorised task push plus a plain-text command surface (see 4.4); a per-project line limit (800 by default) is scanned at the end of every run, and an over-limit file triggers one 【系统指令】 asking the director to schedule a split card.
78
+
79
+ ---
80
+
81
+ ## 4. Architecture and Layout
82
+
83
+ ### 4.1 Wiring
84
+
85
+ `apply(ctx, config)` in `index.js` is the only entry point, and it assembles the layers in dependency order — configuration, database, domain service, host runtime, team tools, skill pool, HTTP. `service.initialize()` then creates the database and seeds the default bots and buddies before `service.start()` brings up the scheduler.
86
+
87
+ ### 4.2 The `src/` directory
88
+
89
+ | Path | Responsibility |
90
+ | --- | --- |
91
+ | `index.js`, `src/config.js`, `src/db.js`, `src/db-migrations.js` | plugin entry point; configuration resolution; SQLite access and idempotent migrations |
92
+ | `src/service.js`, `src/services/`, `src/runtime.js`, `src/services/runtime/` | the `TeamService` facade and its domain methods; the host adapter (prompts, sessions, model recovery, trajectories) |
93
+ | `src/http.js`, `src/api.js`, `src/tools.js`, `src/botmsg.js`, `src/skill-parse.js` | HTTP routes and UI slices; the `/api/dsh-team/api` dispatch entry; team tools; bot-to-bot messages; skill parsing |
94
+ | `src/wechat/`, `src/secrets.js`, `src/pricing.js`, `src/usage*.js`, `src/skills*.js`, `src/seed-bots.js`, `src/updater.js`, `src/paths.js`, `src/util.js`, `src/errors.js` | WeChat channel; secret crypto; pricing and usage; skill pools; seed bots; update check; path boundaries; utilities; error types |
95
+
96
+ ### 4.3 The `ui/` directory
97
+
98
+ The frontend is plain ES modules with no build step; every slice is loaded straight from an HTTP route. `ui/modules/` holds one module per domain, `ui/styles/` one CSS file per domain, and `ui/i18n/{zh,en}.js` the interface dictionaries. Contribution rules for this tree (style-slice registration, the 800-line limit) are in `CONTRIBUTING.md`.
99
+
100
+ ### 4.4 The WeChat channel
101
+
102
+ The channel is off by default (`DSH_TEAM_WECHAT=0`) and becomes active after QR authorisation. Its command surface is plain text, and `帮助 / help / ?` pulls it up at any time:
103
+
104
+ | Command | Effect |
105
+ | --- | --- |
106
+ | `帮助` / `help` / `?` | show the command help |
107
+ | `状态` | overview of the projects and the tasks pending review |
108
+ | `验收 <task number> [comment]` | accept a delivery, e.g. `验收 web-3 做得好` |
109
+ | `驳回 <task number> <reason>` | send it back for rework; the reason is mandatory |
110
+ | `详情 <task number>` | show the task card and its latest comments |
111
+ | `q` | list the project keys that can be assigned |
112
+ | `<key>: <message>` | forward a message into the project chat for the director to arrange, e.g. `web: 上线新版官网` |
113
+
114
+ Pushes go through a local outbox; its discard policy (retry budget, batching window, connection-epoch retention) is defined in `src/wechat/channel.js`. When investigating a missed push, `outbox.attempts` and `gave_up_at` tell you whether the item was dropped by design or is still queued.
115
+
116
+ ---
117
+
118
+ ## 5. Testing and Development Conventions
119
+
120
+ ### 5.1 Common commands
121
+
122
+ ```sh
123
+ npm test # node --test "tests/*.test.js"
124
+ npm run dev # local preview (fake runtime)
125
+ npm run doctor # check Node/DSH versions and the writability of the workspace and skill-pool paths
126
+ npm run profile:install # pack and reinstall into a profile (team-bots by default)
127
+ npm run backup # back up the team data
128
+ npm run restore-check # check that a backup can be restored
129
+ ```
130
+
131
+ ### 5.2 Guard tests and commit conventions
132
+
133
+ `npm test` covers every feature domain plus the architectural pins. The guard-test details, the commit conventions and the `ui/` contribution rules are in `CONTRIBUTING.md`.
134
+
135
+ ### 5.3 CI
136
+
137
+ Pushing a `v*` tag triggers the publish workflow (`.github/workflows/publish.yml`): it installs dependencies, runs the full `npm test`, and only publishes to registry.npmjs.org when everything is green.
138
+
139
+ ---
140
+
141
+ ## 6. Troubleshooting and FAQ
142
+
143
+ **Q: I changed the code but the page is still the old one?**
144
+ The plugin files inside a profile are a snapshot and are not hot-reloaded. Reinstall with `npm run profile:install -- --profile <name>`. A page stuck at "connecting to the team space" usually has the same cause.
145
+
146
+ **Q: Where does the data live, and how do I take it to another machine?**
147
+ Under `<DSH_TEAM_DATA>` are `team.sqlite`, `wechat-channel.sqlite`, `secret.key`, `memory/` and `messages/`. Back it up with `npm run backup`, and **do not leave `secret.key` behind** — without it the existing ciphertext can never be decrypted again.
148
+
149
+ **Q: WeChat did not receive the push?**
150
+ Look at `outbox.attempts` and `gave_up_at` first: a value means the item was dropped by design, not missed; no value means it is still in the queue.
151
+
152
+ **Q: What is the "code hygiene" alert in the project chat?**
153
+ At the end of every run the source files in the project workspace are scanned, and a file over the project's line limit (800 by default, judgement line 880) triggers one 【系统指令】 asking the director to schedule a split card. Raise the limit in the project settings, or set it to 0 to switch the check off.
154
+
155
+ **Q: Can it be exposed to the public internet?**
156
+ The plugin ships no sandbox: bot sessions run under DSH's `danger-full-access` as the current user. Together with auto-login (reaching the port means owner), public exposure requires an HTTPS reverse proxy and your own authentication; teams that do not trust each other should not share one DSH instance and workspace.
157
+
158
+ ---
159
+
160
+ ## Screenshots
161
+
162
+ Usage stats carry the summary window, the last 14 days of detail, a per-model / per-bot / per-project breakdown and a CSV export:
163
+
164
+ ![Usage stats](docs/assets/usage.png)
165
+
166
+ The global configuration page keeps only the core groups — preferences, run limits and ops; channels, secrets, version status and pricing rules live on their own top-level pages:
167
+
168
+ ![Global configuration](docs/assets/global-config-light.png)
169
+
170
+ ---
171
+
172
+ ## License
173
+
174
+ Apache-2.0, see `LICENSE` and `NOTICE` in the repository root.
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-team-bots
3
+ name: dsh-team-bots
@@ -0,0 +1,174 @@
1
+ # DSH Team Bots
2
+
3
+ [English](../README.md)
4
+
5
+ DSH Team Bots 是 npm 包 `dsh-team-bots`,一个 DSH(DeepSeek Harness)插件,把一整个协作的 bot 团队装进同一个工作区:项目群聊、任务板、按写范围并行调度、记忆与技能、用量与成本,外加一条个人微信通道。
6
+
7
+ ![DSH Team Bots 工作区](assets/tasks.png)
8
+
9
+ 本文件是项目文档的中文版,英文版见 [../README.md](../README.md)。
10
+
11
+ ---
12
+
13
+ ## 1. 项目简介与定位
14
+
15
+ `dsh-team-bots` 跑在 DSH Web 进程里 —— 没有独立服务 —— 让多个 bot 在同一个项目空间里分工,并把整个协作暴露成一个可操作的 Web 工作区。
16
+
17
+ 1. **协作发生在项目里,而不是聊天窗里。** 每个项目有自己的群聊、成员、任务和工作目录;项目 director bot 在那里拆分、派发和验收工作。
18
+ 2. **并行是声明出来的,不是碰运气。** 任务声明它会写哪些路径;调度器只在两个写 run 都声明、且写路径前缀互不重叠时,才让它们在同一项目里并行。没声明的一律按串行处理。
19
+ 3. **一切可追溯。** 每个 run 都保留轨迹、时长、token 数和成本;bot 配置保留可回滚的不可变历史;密钥在落盘时加密,使用时才物化成一次性明文文件,用完即焚。
20
+
21
+ 仓库结构:`index.js` 是插件入口,`src/` 是服务端与调度器,`ui/` 是工作区前端,`tests/` 是守门测试,`docs/` 是设计稿、评审记录和截图。
22
+
23
+ ---
24
+
25
+ ## 2. 快速开始
26
+
27
+ ### 2.1 环境要求与安装
28
+
29
+ Node.js ≥ 22.19(见 `package.json` 的 `engines`),并装好 DSH CLI(`dsh --version`);插件跑在 DSH Web 进程里,没有独立进程和端口。
30
+
31
+ ```sh
32
+ cd <repo>
33
+ npm pack # 产出 dsh-team-bots-<version>.tgz
34
+ dsh plugin --profile <name> add ./dsh-team-bots-<version>.tgz
35
+ dsh --profile <name> # 从启动日志里读带 token 的 dsh web 入口
36
+ ```
37
+
38
+ ### 2.2 重装与本地预览
39
+
40
+ ```sh
41
+ npm run profile:install -- --profile <name> # 省略 --profile 时装进 team-bots
42
+ npm run dev # 本地预览 http://127.0.0.1:4317,假 runtime
43
+ ```
44
+
45
+ `profile:install` 把仓库打包并重装进 profile。**profile 里的插件文件是快照,DSH 不会自动加载替换后的文件**:改了代码必须重装,否则页面会卡在「connecting to the team space」。团队数据与 profile 解耦:数据目录只由 `DSH_TEAM_WORKSPACE` / `DSH_TEAM_DATA` 决定。预览服务器用的是假 DSH runtime —— **不做鉴权、不动 DSH 配置、不可用于生产**;端口可用 `PORT` 覆盖。
46
+
47
+ ### 2.3 数据、密钥与技能放在哪
48
+
49
+ 数据位于 `DSH_TEAM_DATA`(缺省 `<workspace>/.data`,工作区根目录 `DSH_TEAM_WORKSPACE`,缺省 `~/.dsh/workspace/team-bots`):`team.sqlite`、`wechat-channel.sqlite`、`secret.key`、`memory/`、`messages/` 和 `secrets-runtime/`(TTL 到期即焚)。备份时请把 `secret.key` 一起带走 —— 没有它,已有的密文永远解不开。表结构变更走 `src/db-migrations.js` 的幂等迁移。技能来自固定在 `~/.agents/skills` 的共享池,以及项目本地的 `<project>/.agents/skills`、`<project>/.claude/skills`、`<project>/.codex/skills`。
50
+
51
+ 常用变量的模板在 `.env.example`;**不要把 `.env` 放在仓库根目录**,否则 `DSH_*` 会漏进 `npm test` 和 `npm run dev`。
52
+
53
+ ### 2.4 访问入口与常用环境变量
54
+
55
+ ```text
56
+ http://<host>:<port>/ 自动登录,直接进入团队工作区
57
+ http://<host>:<port>/api/dsh-team/ui DSH Team Bots 工作区(直达)
58
+ http://<host>:<port>/index.html DSH 原生 Web UI
59
+ ```
60
+
61
+ 首次访问首页会用当前启动 token 换一张 30 天登录 cookie。自动登录意味着**任何能访问到端口的人都是 owner**,所以请只监听本机或可信网络;要公网暴露,需要一个正确转发 Host 与 WebSocket 的 HTTPS 反向代理。
62
+
63
+ 真正要紧的两个路径是 `DSH_TEAM_WORKSPACE`(团队工作区根目录)和 `DSH_TEAM_DATA`(团队数据库与 run 记录);其余变量、缺省值和解析顺序(显式 env > 页面保存值 > 代码缺省)都在 `src/config.js`。
64
+
65
+ ---
66
+
67
+ ## 3. 功能总览
68
+
69
+ - **项目群聊:** 每个项目一个群聊、一个 director bot。支持纯文本、`@Bot`、`/task @Bot <标题>`、`/remember` 和 `/clear`,`/` 与 `@` 可补全命令、技能和成员。结论留在聊天里,完整交付走任务评论。
70
+ - **任务板:** Linear 风格、按状态分组的面板,带父子树、优先级与负责人,评论会送进正在跑的会话,支持拖拽流转,行内展示交付物和 run 列表。
71
+ - **按写范围并行调度:** 由声明的写范围决定同一项目的两个写 run 能否同时跑;写 run 彼此独立,任务和聊天互不阻塞。
72
+ - **记忆与技能池:** bot 级和项目级长期记忆,带人工审核队列;共享技能池固定在 `~/.agents/skills`,项目可追加自己的技能目录;技能变更走提案审批并保留回滚快照。
73
+ - **版本化演进与团队工具:** 角色、模型、强度和技能变更走提案审批,bot 配置保留不可变、可回滚的历史。插件注册了任务派发、评审、记忆、召回、演进提案、bot 间直发消息和密钥申请等团队工具。
74
+ - **密钥流水线:** 落盘用 AES-256-GCM;审批通过后物化到数据目录(**不是项目工作区**),run 结束或 TTL 到期即焚;消息和 run 输出里始终以 `$<name>` 掩码。
75
+ - **用量与成本:** token、调用次数、成本和运行时长按全局、项目、bot 三级汇总;成本来自可配置的模型价格,未配置价格的调用不按 0 计费;支持 CSV 导出和月度对账。
76
+ - **审批、提问与终端:** 提权或要人回答的请求变成工作区卡片 —— 审批超时变 `rejected`,提问过期后仍可回答。每个项目有一个交互式终端,带硬超时、实时 tail、取消和持久历史。
77
+ - **微信通道与代码卫生:** 扫码授权后推送任务,外加纯文本命令面(见 4.4);每个项目有行数上限(缺省 800),每个 run 结束时扫描,超限文件触发一条【系统指令】请 director 派拆分卡。
78
+
79
+ ---
80
+
81
+ ## 4. 架构与目录说明
82
+
83
+ ### 4.1 装配链路
84
+
85
+ `index.js` 里的 `apply(ctx, config)` 是唯一入口,它按依赖顺序把各层装起来 —— 配置、数据库、领域服务、宿主 runtime、团队工具、技能池、HTTP。`service.initialize()` 先建库、播种缺省 bot 与 buddy,之后 `service.start()` 才拉起调度器。
86
+
87
+ ### 4.2 `src/` 目录
88
+
89
+ | 路径 | 职责 |
90
+ | --- | --- |
91
+ | `index.js`、`src/config.js`、`src/db.js`、`src/db-migrations.js` | 插件入口;配置解析;SQLite 访问与幂等迁移 |
92
+ | `src/service.js`、`src/services/`、`src/runtime.js`、`src/services/runtime/` | `TeamService` 门面及其领域方法;宿主适配器(提示词、会话、模型恢复、轨迹) |
93
+ | `src/http.js`、`src/api.js`、`src/tools.js`、`src/botmsg.js`、`src/skill-parse.js` | HTTP 路由与 UI 切片;`/api/dsh-team/api` 分发入口;团队工具;bot 间消息;技能包解析 |
94
+ | `src/wechat/`、`src/secrets.js`、`src/pricing.js`、`src/usage*.js`、`src/skills*.js`、`src/seed-bots.js`、`src/updater.js`、`src/paths.js`、`src/util.js`、`src/errors.js` | 微信通道;密钥加解密;定价与用量;技能池;种子 bot;更新检查;路径边界;工具函数;错误类型 |
95
+
96
+ ### 4.3 `ui/` 目录
97
+
98
+ 前端是纯 ES 模块,无构建步骤,每个切片由 HTTP 路由直接加载。`ui/modules/` 每个领域一个模块,`ui/styles/` 每个领域一个 CSS 文件,`ui/i18n/{zh,en}.js` 是界面字典。这棵树的贡献约定(样式切片注册、800 行铁律)见 `CONTRIBUTING.md`。
99
+
100
+ ### 4.4 微信通道
101
+
102
+ 通道缺省关闭(`DSH_TEAM_WECHAT=0`),扫码授权后启用。命令面是纯文本,随时可用 `帮助 / help / ?` 唤出:
103
+
104
+ | 命令 | 作用 |
105
+ | --- | --- |
106
+ | `帮助` / `help` / `?` | 显示命令帮助 |
107
+ | `状态` | 项目与待验收任务总览 |
108
+ | `验收 <任务号> [评语]` | 验收交付,如 `验收 web-3 做得好` |
109
+ | `驳回 <任务号> <原因>` | 打回重做,原因必填 |
110
+ | `详情 <任务号>` | 显示任务卡与最新评论 |
111
+ | `q` | 列出可指派的项目 key |
112
+ | `<key>: <消息>` | 转发消息到项目群聊交 director 安排,如 `web: 上线新版官网` |
113
+
114
+ 推送走本地 outbox,其丢弃策略(重试预算、批量窗口、连接周期保留)定义在 `src/wechat/channel.js`。排查漏推时看 `outbox.attempts` 和 `gave_up_at`:有值说明该条目是被设计丢弃的,没值说明还在队列里。
115
+
116
+ ---
117
+
118
+ ## 5. 测试与开发约定
119
+
120
+ ### 5.1 常用命令
121
+
122
+ ```sh
123
+ npm test # node --test "tests/*.test.js"
124
+ npm run dev # 本地预览(假 runtime)
125
+ npm run doctor # 检查 Node/DSH 版本,以及工作区与技能池路径的可写性
126
+ npm run profile:install # 打包并重装进 profile(缺省 team-bots)
127
+ npm run backup # 备份团队数据
128
+ npm run restore-check # 检查备份能否恢复
129
+ ```
130
+
131
+ ### 5.2 守门测试与提交约定
132
+
133
+ `npm test` 覆盖每个功能域,另加几条架构约定的钉子。守门测试细节、提交约定和 `ui/` 贡献约定都在 `CONTRIBUTING.md`。
134
+
135
+ ### 5.3 CI
136
+
137
+ 推送 `v*` tag 触发发布工作流(`.github/workflows/publish.yml`):装依赖、跑完整 `npm test`,全绿才发布到 registry.npmjs.org。
138
+
139
+ ---
140
+
141
+ ## 6. 故障排查与常见问题
142
+
143
+ **Q:改了代码,页面还是旧的?**
144
+ profile 里的插件文件是快照,不会热加载。用 `npm run profile:install -- --profile <name>` 重装。页面卡在「connecting to the team space」通常也是同一个原因。
145
+
146
+ **Q:数据在哪,怎么搬到另一台机器?**
147
+ `<DSH_TEAM_DATA>` 下有 `team.sqlite`、`wechat-channel.sqlite`、`secret.key`、`memory/` 和 `messages/`。用 `npm run backup` 备份,**不要把 `secret.key` 落下** —— 没有它,已有密文永远解不开。
148
+
149
+ **Q:微信没收到推送?**
150
+ 先看 `outbox.attempts` 和 `gave_up_at`:有值说明条目是被设计丢弃的,不是漏发;没值说明还在队列里。
151
+
152
+ **Q:项目聊天里的「代码卫生」提醒是什么?**
153
+ 每个 run 结束时会扫描项目工作区里的源文件,超过项目行数上限(缺省 800,判定线 880)的文件会触发一条【系统指令】请 director 派拆分卡。可在项目设置里调高上限,或设为 0 关闭检查。
154
+
155
+ **Q:能暴露到公网吗?**
156
+ 插件本身不带沙箱:bot 会话以当前用户身份跑在 DSH 的 `danger-full-access` 下。加上自动登录(能访问端口就是 owner),公网暴露需要 HTTPS 反向代理和自有鉴权;互不信任的团队不应共用同一个 DSH 实例和工作区。
157
+
158
+ ---
159
+
160
+ ## 截图
161
+
162
+ 用量统计带汇总窗口、最近 14 天明细、按模型 / 按 bot / 按项目拆分和 CSV 导出:
163
+
164
+ ![用量统计](assets/usage.png)
165
+
166
+ 全局配置页只保留偏好、运行时效与系统运维核心组;通道、密钥、版本与价格规则在各自的一级页:
167
+
168
+ ![全局配置](assets/global-config-light.png)
169
+
170
+ ---
171
+
172
+ ## License
173
+
174
+ Apache-2.0,见仓库根目录的 `LICENSE` 和 `NOTICE`。
Binary file
Binary file
Binary file
package/index.js ADDED
@@ -0,0 +1,41 @@
1
+ import { resolveConfig } from './src/config.js'
2
+ import { openDatabase } from './src/db.js'
3
+ import { installHttp } from './src/http.js'
4
+ import { DshRuntime } from './src/runtime.js'
5
+ import { TeamService } from './src/service.js'
6
+ import { installSkillProvider } from './src/skills.js'
7
+ import { installTeamTools } from './src/tools.js'
8
+
9
+ export const name = 'dsh-team-bots'
10
+ export const inject = ['llm', 'tools', 'systemPrompt', 'sessionController', 'sessionTitle', 'connection', 'webServer']
11
+
12
+ export function apply(ctx, config = {}) {
13
+ const resolved = resolveConfig(config)
14
+ const logger = {
15
+ info: (...args) => console.log('[dsh-team]', ...args),
16
+ warn: (...args) => console.warn('[dsh-team]', ...args),
17
+ error: (...args) => console.error('[dsh-team]', ...args),
18
+ }
19
+ const store = openDatabase(resolved.dbPath)
20
+ const service = new TeamService({ store, config: resolved, logger })
21
+ const runtime = new DshRuntime({ ctx, config: resolved, store, logger })
22
+ service.attachRuntime(runtime)
23
+ runtime.attach()
24
+ installTeamTools(ctx, service)
25
+ installSkillProvider(ctx, resolved, logger, store)
26
+ installHttp(ctx, service, logger)
27
+
28
+ ctx.effect?.(() => () => {
29
+ service.stop()
30
+ store.close()
31
+ }, 'dsh-team: shutdown')
32
+
33
+ const boot = service.initialize().then(() => {
34
+ service.start()
35
+ logger.info('ready: workspace=%s data=%s', resolved.workspace, resolved.dataDir)
36
+ }).catch(error => {
37
+ logger.error('startup failed: %s', error?.stack ?? error)
38
+ })
39
+ service.boot = boot
40
+ return { service, runtime, store }
41
+ }