dsh-env-manager-plugin 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +249 -2
  3. package/client.js +2581 -0
  4. package/cordis.patch.yml +4 -0
  5. package/docs/00-project/current-state.md +246 -0
  6. package/docs/00-project/glossary.md +215 -0
  7. package/docs/00-project/project-brief.md +114 -0
  8. package/docs/00-project/roadmap.md +89 -0
  9. package/docs/01-architecture/DSH_Environment_Service_Memory_Skill_Brainstorm.md +493 -0
  10. package/docs/01-architecture/api-verification.md +416 -0
  11. package/docs/01-architecture/architecture-overview.md +222 -0
  12. package/docs/01-architecture/data-model.md +930 -0
  13. package/docs/01-architecture/decisions/ADR-0001-plugin-as-bundle.md +29 -0
  14. package/docs/01-architecture/decisions/ADR-0002-file-based-storage.md +25 -0
  15. package/docs/01-architecture/decisions/ADR-0003-skill-router-over-search.md +25 -0
  16. package/docs/01-architecture/decisions/ADR-0004-typescript-host-js-client.md +31 -0
  17. package/docs/01-architecture/decisions/ADR-0005-layered-rule-resolution.md +36 -0
  18. package/docs/01-architecture/decisions/ADR-0006-credentials-as-references.md +30 -0
  19. package/docs/01-architecture/decisions/ADR-0007-session-scoped-default-environment.md +28 -0
  20. package/docs/01-architecture/decisions/ADR-0008-memory-bridge-not-second-store.md +31 -0
  21. package/docs/01-architecture/decisions/ADR-0009-client-host-http-transport.md +87 -0
  22. package/docs/01-architecture/decisions/ADR-0010-environment-plane-model.md +87 -0
  23. package/docs/01-architecture/decisions/ADR-0011-k8s-node-execution-model.md +92 -0
  24. package/docs/01-architecture/design.md +666 -0
  25. package/docs/01-architecture/detailed-design.md +961 -0
  26. package/docs/01-architecture/implementation-plan.md +323 -0
  27. package/docs/01-architecture/module-boundaries.md +306 -0
  28. package/docs/01-architecture/security-model.md +227 -0
  29. package/docs/01-architecture/storage-contract.md +224 -0
  30. package/docs/01-architecture/tool-contract.md +438 -0
  31. package/docs/01-architecture/ui-design.md +587 -0
  32. package/docs/02-harness/agent-behavior.md +36 -0
  33. package/docs/02-harness/change-snapshot-policy.md +29 -0
  34. package/docs/02-harness/client-ui-integration.md +110 -0
  35. package/docs/02-harness/context-policy.md +43 -0
  36. package/docs/02-harness/harness-standard.md +91 -0
  37. package/docs/02-harness/task-execution-policy.md +26 -0
  38. package/docs/02-harness/verification-policy.md +97 -0
  39. package/docs/03-openspec/archive-rule.md +25 -0
  40. package/docs/03-openspec/bugfix-rule.md +30 -0
  41. package/docs/03-openspec/design-rule.md +33 -0
  42. package/docs/03-openspec/openspec-usage-guide.md +31 -0
  43. package/docs/03-openspec/proposal-rule.md +70 -0
  44. package/docs/03-openspec/spec-rule.md +33 -0
  45. package/docs/03-openspec/tasks-rule.md +31 -0
  46. package/docs/04-development/coding-style.md +67 -0
  47. package/docs/04-development/dependency-policy.md +43 -0
  48. package/docs/04-development/development-guide.md +85 -0
  49. package/docs/04-development/directory-convention.md +105 -0
  50. package/docs/04-development/local-run-guide.md +55 -0
  51. package/docs/04-development/testing-guide.md +102 -0
  52. package/docs/05-domain/deployment-template.md +76 -0
  53. package/docs/05-domain/environment-template.md +165 -0
  54. package/docs/05-domain/operation-binding-template.md +55 -0
  55. package/docs/05-domain/operation-record-template.md +55 -0
  56. package/docs/05-domain/prompt-template.md +90 -0
  57. package/docs/05-domain/rule-template.md +73 -0
  58. package/docs/05-domain/service-template.md +39 -0
  59. package/docs/06-operations/deployment-guide.md +54 -0
  60. package/docs/06-operations/release.md +188 -0
  61. package/docs/06-operations/security-policy.md +53 -0
  62. package/docs/06-operations/troubleshooting.md +91 -0
  63. package/docs/07-templates/adr-template.md +21 -0
  64. package/docs/07-templates/bugfix-template.md +11 -0
  65. package/docs/07-templates/case-template.md +15 -0
  66. package/docs/07-templates/design-template.md +29 -0
  67. package/docs/07-templates/proposal-template.md +19 -0
  68. package/docs/07-templates/spec-template.md +15 -0
  69. package/docs/07-templates/tasks-template.md +12 -0
  70. package/docs/99-archive/README.md +13 -0
  71. package/docs/README.md +142 -0
  72. package/icon.svg +4 -0
  73. package/index.js +8 -0
  74. package/lib/app/app.d.ts +67 -0
  75. package/lib/app/app.js +494 -0
  76. package/lib/app/app.js.map +1 -0
  77. package/lib/config.d.ts +55 -0
  78. package/lib/config.js +42 -0
  79. package/lib/config.js.map +1 -0
  80. package/lib/domain/constants.d.ts +21 -0
  81. package/lib/domain/constants.js +59 -0
  82. package/lib/domain/constants.js.map +1 -0
  83. package/lib/domain/errors.d.ts +20 -0
  84. package/lib/domain/errors.js +22 -0
  85. package/lib/domain/errors.js.map +1 -0
  86. package/lib/domain/schemas.d.ts +28 -0
  87. package/lib/domain/schemas.js +445 -0
  88. package/lib/domain/schemas.js.map +1 -0
  89. package/lib/domain/types.d.ts +412 -0
  90. package/lib/domain/types.js +2 -0
  91. package/lib/domain/types.js.map +1 -0
  92. package/lib/index.d.ts +18 -0
  93. package/lib/index.js +89 -0
  94. package/lib/index.js.map +1 -0
  95. package/lib/logger.d.ts +8 -0
  96. package/lib/logger.js +13 -0
  97. package/lib/logger.js.map +1 -0
  98. package/lib/memory/bridge.d.ts +18 -0
  99. package/lib/memory/bridge.js +13 -0
  100. package/lib/memory/bridge.js.map +1 -0
  101. package/lib/registry/integrity.d.ts +10 -0
  102. package/lib/registry/integrity.js +204 -0
  103. package/lib/registry/integrity.js.map +1 -0
  104. package/lib/registry/registry.d.ts +14 -0
  105. package/lib/registry/registry.js +182 -0
  106. package/lib/registry/registry.js.map +1 -0
  107. package/lib/resolver/merge.d.ts +23 -0
  108. package/lib/resolver/merge.js +90 -0
  109. package/lib/resolver/merge.js.map +1 -0
  110. package/lib/resolver/resolve.d.ts +18 -0
  111. package/lib/resolver/resolve.js +288 -0
  112. package/lib/resolver/resolve.js.map +1 -0
  113. package/lib/resolver/template.d.ts +10 -0
  114. package/lib/resolver/template.js +42 -0
  115. package/lib/resolver/template.js.map +1 -0
  116. package/lib/router/params.d.ts +3 -0
  117. package/lib/router/params.js +83 -0
  118. package/lib/router/params.js.map +1 -0
  119. package/lib/router/router.d.ts +11 -0
  120. package/lib/router/router.js +204 -0
  121. package/lib/router/router.js.map +1 -0
  122. package/lib/session/session.d.ts +16 -0
  123. package/lib/session/session.js +64 -0
  124. package/lib/session/session.js.map +1 -0
  125. package/lib/skill.d.ts +17 -0
  126. package/lib/skill.js +56 -0
  127. package/lib/skill.js.map +1 -0
  128. package/lib/storage/atomic.d.ts +10 -0
  129. package/lib/storage/atomic.js +107 -0
  130. package/lib/storage/atomic.js.map +1 -0
  131. package/lib/storage/paths.d.ts +10 -0
  132. package/lib/storage/paths.js +50 -0
  133. package/lib/storage/paths.js.map +1 -0
  134. package/lib/storage/records.d.ts +16 -0
  135. package/lib/storage/records.js +112 -0
  136. package/lib/storage/records.js.map +1 -0
  137. package/lib/storage/sessions.d.ts +17 -0
  138. package/lib/storage/sessions.js +65 -0
  139. package/lib/storage/sessions.js.map +1 -0
  140. package/lib/tools/tools.d.ts +14 -0
  141. package/lib/tools/tools.js +472 -0
  142. package/lib/tools/tools.js.map +1 -0
  143. package/lib/transport/http.d.ts +3 -0
  144. package/lib/transport/http.js +217 -0
  145. package/lib/transport/http.js.map +1 -0
  146. package/locale/en.json +6 -0
  147. package/locale/zh.json +6 -0
  148. package/package.json +97 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH Environment Manager Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,250 @@
1
- # Temporary Holding Version
1
+ # DSH Environment Manager
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
+ A [DSH (DeepSeek Harness)](https://www.deepseek.com/) plugin that gives every session a shared, queryable view of enterprise environments, services, deployments and operation-to-Skill bindings.
4
+
5
+ Works in DSH Web and Desktop.
6
+
7
+ > 中文简介:这是一个 DSH 插件,让每个会话都能按需读取企业运行环境、服务目录、部署实例、分层规则以及操作与 Skill 的绑定关系。
8
+
9
+ ## What it does
10
+
11
+ - **Environment Registry** — hosts, clusters, logical roles, access endpoints, host
12
+ accounts and login audit records in one record.
13
+ - **Service Catalog** — Git URL, default branch, build tool, artifact and rule profile references.
14
+ - **Deployment Binding** — which service runs where, as `native`, `docker` or `kubernetes`, with instance-level variables.
15
+ - **Rule Resolver** — layered, field-level overrides with full provenance: every value explains where it came from and what influenced it.
16
+ - **Operation Skill Router** — maps an operation (deploy, redeploy, collect-logs, …) to exactly one bound Skill, detecting conflicts and enforcing approval policy.
17
+ - **Session Context** — a per-session default environment that never leaks into another session.
18
+ - **Discovery Skill** — a profile-wide `dsh-env-manager` Skill registers with the plugin and
19
+ makes the registry discoverable from any workspace in the same profile; its full workflow
20
+ loads only when invoked.
21
+ - **Memory Bridge** — a contract for feeding scoped, redacted operation records into the DSH memory plugin (P1).
22
+
23
+ ## Status
24
+
25
+ **Phase 1 of the environment/plane model and Phase 1.1 of the K8s node/execution model are
26
+ implemented and installed in the `desktop` profile.**
27
+
28
+ - 50 Vitest tests pass; `npm run build` emits `lib/`.
29
+ - Ten `env_*` tools, the same-origin `/env-manager/api` route and the sidebar/main panel
30
+ are implemented.
31
+ - One environment is one complete network and one configuration page. Management,
32
+ business, database and expansion are **role views** over the same `hosts[]`; a node
33
+ serving two planes is one host with two roles.
34
+ - The environment detail page is split into overview, all nodes, one tab per plane, login
35
+ records, Kubernetes/clusters, endpoints and YAML. Plane tabs filter the same node
36
+ collection.
37
+ - `New environment` creates only the environment shell and seeds the four standard roles.
38
+ Nodes are added inside the environment, individually or by batch import.
39
+ - Add/edit node supports multiple roles, a machine kind (`vm`, `physical`, K8s all-in-one,
40
+ K8s worker, Pod host), command access (`ssh`, `kubectl`, `docker`) and an optional login
41
+ credential. K8s kinds reference a cluster; a Pod host is the machine reached with
42
+ `docker exec`, not one record per Pod. Batch import (`IP,name,roles,port,user`) creates
43
+ generic VM nodes and never accepts passwords. Node search covers id, name, IP, platform,
44
+ admin user, role, kind, access, cluster, account username and web login URL.
45
+ - Accounts can carry a web login URL and username for a management or business console.
46
+ `Add web login` opens the account form with protocol `web`; `Edit account` can change the
47
+ URL or rotate the password. A password is written to the DSH credential service, never to
48
+ YAML.
49
+ - The Kubernetes/clusters tab creates and edits cluster metadata (kind, topology, API
50
+ endpoint, namespaces, credential reference) and derives node counts from `clusterRef`.
51
+ - Passwords are written to the DSH credential service; YAML keeps only
52
+ `env-manager/<environmentId>/<hostId>-<username>`.
53
+ - **环境 (Environments) is the default tab**, and the persistent header **新增环境**
54
+ action is available from every tab. `记录 (Records)` is limited to services,
55
+ deployments, rule profiles and operation bindings.
56
+ - Remaining: database primary/replica/sharding topology (Phase 2), row-level delete for
57
+ nodes/accounts/logins, light-theme visual QA, and the live approval/credential probes
58
+ V4 and V6.
59
+ - No operation execution: routing returns the bound Skill and policy, it does not run it.
60
+
61
+ ## How agents discover the registry
62
+
63
+ The plugin ships a **discovery Skill** named `dsh-env-manager` as part of the same bundle.
64
+ It is not a separate `SKILL.md`, and it is not installed separately.
65
+
66
+ How it works:
67
+
68
+ 1. `apply()` registers the Skill through `ctx.skills.register()` from the plugin's
69
+ unscoped context. DSH files it into the global Skill layer for the current profile.
70
+ 2. The Skill catalog carries only the name, description and `whenToUse`. That description
71
+ is the **proactive mention** that lets a new workspace discover the registry.
72
+ 3. The full workflow body is loaded only when the model or user invokes the Skill. It tells
73
+ the agent to use `env_list` / `env_find` first, then `env_set_context`, `env_resolve`,
74
+ and `env_resolve_operation`.
75
+ 4. The plugin does **not** inject a global system-prompt section. Unrelated coding sessions
76
+ do not receive environment-manager instructions.
77
+ 5. The registration is created inside the plugin effect, so disabling or uninstalling the
78
+ plugin also removes the Skill.
79
+ 6. `registerSkill: false` in the plugin config suppresses the entry without affecting the
80
+ tools or panel.
81
+
82
+ Scope and limits:
83
+
84
+ - **Same DSH profile:** every workspace, including a new empty one, sees the Skill in its
85
+ catalog; no workspace `AGENTS.md` is required. This was verified from an empty temporary
86
+ workspace.
87
+ - **Different profile or machine:** the Skill is not shared; install the bundle there.
88
+ - The Skill is **discovery, not execution**. It does not deploy, restart or collect logs.
89
+ Those actions still need an `operationBinding` that points to an execution Skill.
90
+ - A catalog entry is a trigger surface, not a hard guarantee. Critical operations must still
91
+ be enforced in the execution Skill or tool layer.
92
+ - Because the Skill is registered by the plugin, its content is versioned with the plugin;
93
+ there is no workspace copy to drift.
94
+
95
+ The plugin's own tools remain registered independently of this Skill. The Skill only makes
96
+ the registry discoverable and explains the intended workflow.
97
+
98
+ > 中文:`dsh-env-manager` 随插件一起注册,**不单独安装**;同一 DSH profile 下的所有工作区
99
+ > 都能在 Skill 目录看到它,正文按需加载;**不注入全局系统提示**。它只负责发现和指导,
100
+ > 不执行部署/重启;真正的执行仍由 `operationBinding` 指向的执行 Skill 完成。
101
+
102
+ ## Add an environment
103
+
104
+ 1. Open **环境管理器** (Environment Manager); it opens on the **环境 (Environments)** tab.
105
+ 2. Click **新增环境** (New environment) in the panel header. The same action is available
106
+ from any other tab.
107
+ 3. Fill in the environment name, optional id, category and description. The four standard
108
+ planes are created automatically. Click **创建环境** (Create environment).
109
+ 4. Open the new environment. Use **全部节点** (All nodes) or a plane tab, then
110
+ **添加节点** (Add node). A node may carry several roles.
111
+ 5. To register many nodes, use **批量导入** (Batch import):
112
+ `IP,name,roles,port,user` per line, with `|` or `/` between roles. Batch import creates
113
+ generic VM nodes and optional accounts but no passwords.
114
+ 6. For Kubernetes or Pod-hosting machines, open **K8s / 集群** (Kubernetes / clusters)
115
+ first and add the cluster. Then select the node kind, cluster and command access in
116
+ **添加节点** (Add node). Choose **K8s 合设** when the control plane and worker share a
117
+ machine; choose **Pod 宿主机** for a machine operated through `docker exec`. A Pod itself
118
+ is not added as a node.
119
+ 7. For a management or business web console, open the relevant plane tab and find the node
120
+ that hosts it, then click **添加 Web 登录** (Add web login) on the node card. Enter the
121
+ web login URL, username and (optionally) the password. The URL is stored on the account,
122
+ the password is written to the DSH credential service, and the account can later be
123
+ updated with **编辑账号** (Edit account).
124
+
125
+ A password entered on the node or account form is sent once to the Host and stored by the
126
+ DSH credential service. It never appears in the registry YAML, tool output or logs. Use
127
+ **新建记录** only when you need to paste an advanced YAML template.
128
+
129
+ Design references:
130
+
131
+ - [`docs/01-architecture/design.md`](docs/01-architecture/design.md) — scope, algorithms,
132
+ acceptance criteria;
133
+ - [`docs/01-architecture/decisions/ADR-0010-environment-plane-model.md`](docs/01-architecture/decisions/ADR-0010-environment-plane-model.md) —
134
+ why one network is one environment and planes are role views;
135
+ - [`docs/01-architecture/decisions/ADR-0011-k8s-node-execution-model.md`](docs/01-architecture/decisions/ADR-0011-k8s-node-execution-model.md) —
136
+ why K8s/Pod hosts are machines with command surfaces, not a new plane;
137
+ - [`docs/01-architecture/detailed-design.md`](docs/01-architecture/detailed-design.md) —
138
+ module contracts, storage, tools, HTTP;
139
+ - [`docs/01-architecture/implementation-plan.md`](docs/01-architecture/implementation-plan.md) —
140
+ ordered tasks and cut line;
141
+ - [`docs/01-architecture/api-verification.md`](docs/01-architecture/api-verification.md) —
142
+ runtime facts and remaining probes.
143
+
144
+ ## Installation
145
+
146
+ The npm package is `dsh-env-manager-plugin` (the npm name `dsh-env-manager` is already
147
+ an unrelated package). Install it as a profile bundle; do not install it with
148
+ `npm install -g`.
149
+
150
+ ### From npm (after the first release)
151
+
152
+ ```sh
153
+ dsh plugin --profile <name> add dsh-env-manager-plugin@0.1.0
154
+ ```
155
+
156
+ ### From a local checkout
157
+
158
+ Use the Harness `plugin_manager` tool:
159
+
160
+ ```text
161
+ action: install_bundle
162
+ target: <absolute path to this repository>
163
+ ```
164
+
165
+ Then restart DSH if the bundle was already installed.
166
+
167
+ The bundle includes the `dsh-env-manager` discovery Skill; there is no separate Skill
168
+ installation step. To suppress only the Skill catalog entry, set `config.registerSkill`
169
+ to `false` while keeping the tools and panel:
170
+
171
+ ```yaml
172
+ config:
173
+ registerSkill: false
174
+ ```
175
+
176
+ To remove the whole plugin, call `plugin_manager` with `action: remove_bundle` and
177
+ `target: dsh-env-manager-plugin`.
178
+
179
+ Registry data is created on first run under the resolved `dataDir`; it is not part of the repository.
180
+
181
+ ## Project layout
182
+
183
+ ```text
184
+ dsh-env-manager/
185
+ ├── index.js # Host entry shim over lib/index.js
186
+ ├── client.js # Web/Desktop client module
187
+ ├── cordis.patch.yml # Cordis bundle patch
188
+ ├── package.json # Bundle manifest
189
+ ├── tsconfig.json # Host build config (V1)
190
+ ├── .github/workflows/ # GitHub Actions release pipeline
191
+ ├── src/ # TypeScript Host sources (V1)
192
+ │ └── skill.ts # bundled profile-wide discovery Skill
193
+ ├── lib/ # Build output (git-ignored)
194
+ ├── locale/ # en.json, zh.json
195
+ ├── icon.svg
196
+ ├── docs/ # Design, harness and operations docs
197
+ └── tests/ # Vitest tests (V1)
198
+ ```
199
+
200
+ ## Documentation
201
+
202
+ Start at [`docs/README.md`](docs/README.md).
203
+
204
+ Key documents:
205
+
206
+ | Document | Content |
207
+ |---|---|
208
+ | [`docs/00-project/project-brief.md`](docs/00-project/project-brief.md) | positioning and V1 scope |
209
+ | [`docs/01-architecture/design.md`](docs/01-architecture/design.md) | design, algorithms, acceptance criteria |
210
+ | [`docs/01-architecture/detailed-design.md`](docs/01-architecture/detailed-design.md) | module contracts, tools, HTTP transport |
211
+ | [`docs/01-architecture/data-model.md`](docs/01-architecture/data-model.md) | record schemas |
212
+ | [`docs/01-architecture/tool-contract.md`](docs/01-architecture/tool-contract.md) | model-facing tool surface |
213
+ | [`docs/01-architecture/ui-design.md`](docs/01-architecture/ui-design.md) | panel design and manual QA |
214
+ | [`docs/01-architecture/implementation-plan.md`](docs/01-architecture/implementation-plan.md) | implementation order |
215
+ | [`docs/01-architecture/security-model.md`](docs/01-architecture/security-model.md) | credential and policy controls |
216
+ | [`docs/06-operations/release.md`](docs/06-operations/release.md) | npm Trusted Publisher and GitHub Release pipeline |
217
+
218
+ ## Release
219
+
220
+ Pushing an annotated `v*` tag triggers `.github/workflows/release.yml`: it verifies the
221
+ tag matches `package.json`, runs `npm run check`, packs the npm tarball, publishes with
222
+ npm Trusted Publisher (OIDC), and creates a GitHub Release with the tarball attached.
223
+
224
+ ```sh
225
+ git tag -a v0.1.0 -m "v0.1.0"
226
+ git push origin v0.1.0
227
+ ```
228
+
229
+ The **first** publish must be bootstrapped manually so the npm package exists; bind
230
+ `zhiwuli0228/dsh-env-manager` + `release.yml` as a Trusted Publisher after that. Full
231
+ steps, permissions and failure modes are in
232
+ [`docs/06-operations/release.md`](docs/06-operations/release.md).
233
+
234
+ ## Development
235
+
236
+ ```bash
237
+ npm install
238
+ npm run build
239
+ npm test
240
+ npm run check
241
+ ```
242
+
243
+ `npm run check` runs the typecheck, the build, the Vitest suite and
244
+ `node --check client.js`.
245
+
246
+ See [`docs/04-development/development-guide.md`](docs/04-development/development-guide.md).
247
+
248
+ ## License
249
+
250
+ MIT