dsh-env-manager-plugin 0.1.0 → 0.1.1

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 (78) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +273 -250
  3. package/client.js +2581 -2581
  4. package/cordis.patch.yml +4 -4
  5. package/docs/00-project/current-state.md +32 -6
  6. package/docs/00-project/glossary.md +215 -215
  7. package/docs/00-project/project-brief.md +114 -114
  8. package/docs/00-project/roadmap.md +89 -89
  9. package/docs/01-architecture/DSH_Environment_Service_Memory_Skill_Brainstorm.md +493 -493
  10. package/docs/01-architecture/api-verification.md +416 -416
  11. package/docs/01-architecture/architecture-overview.md +222 -222
  12. package/docs/01-architecture/data-model.md +930 -930
  13. package/docs/01-architecture/decisions/ADR-0001-plugin-as-bundle.md +29 -29
  14. package/docs/01-architecture/decisions/ADR-0002-file-based-storage.md +25 -25
  15. package/docs/01-architecture/decisions/ADR-0003-skill-router-over-search.md +25 -25
  16. package/docs/01-architecture/decisions/ADR-0004-typescript-host-js-client.md +31 -31
  17. package/docs/01-architecture/decisions/ADR-0005-layered-rule-resolution.md +36 -36
  18. package/docs/01-architecture/decisions/ADR-0006-credentials-as-references.md +30 -30
  19. package/docs/01-architecture/decisions/ADR-0007-session-scoped-default-environment.md +28 -28
  20. package/docs/01-architecture/decisions/ADR-0008-memory-bridge-not-second-store.md +31 -31
  21. package/docs/01-architecture/decisions/ADR-0009-client-host-http-transport.md +87 -87
  22. package/docs/01-architecture/decisions/ADR-0010-environment-plane-model.md +87 -87
  23. package/docs/01-architecture/decisions/ADR-0011-k8s-node-execution-model.md +92 -92
  24. package/docs/01-architecture/design.md +666 -666
  25. package/docs/01-architecture/detailed-design.md +961 -961
  26. package/docs/01-architecture/implementation-plan.md +323 -323
  27. package/docs/01-architecture/module-boundaries.md +306 -306
  28. package/docs/01-architecture/security-model.md +227 -227
  29. package/docs/01-architecture/storage-contract.md +224 -224
  30. package/docs/01-architecture/tool-contract.md +438 -438
  31. package/docs/01-architecture/ui-design.md +587 -587
  32. package/docs/02-harness/agent-behavior.md +36 -36
  33. package/docs/02-harness/change-snapshot-policy.md +29 -29
  34. package/docs/02-harness/client-ui-integration.md +110 -110
  35. package/docs/02-harness/context-policy.md +43 -43
  36. package/docs/02-harness/harness-standard.md +91 -91
  37. package/docs/02-harness/task-execution-policy.md +26 -26
  38. package/docs/02-harness/verification-policy.md +97 -97
  39. package/docs/03-openspec/archive-rule.md +25 -25
  40. package/docs/03-openspec/bugfix-rule.md +30 -30
  41. package/docs/03-openspec/design-rule.md +33 -33
  42. package/docs/03-openspec/openspec-usage-guide.md +31 -31
  43. package/docs/03-openspec/proposal-rule.md +70 -70
  44. package/docs/03-openspec/spec-rule.md +33 -33
  45. package/docs/03-openspec/tasks-rule.md +31 -31
  46. package/docs/04-development/coding-style.md +67 -67
  47. package/docs/04-development/dependency-policy.md +43 -43
  48. package/docs/04-development/development-guide.md +85 -85
  49. package/docs/04-development/directory-convention.md +105 -105
  50. package/docs/04-development/local-run-guide.md +61 -55
  51. package/docs/04-development/testing-guide.md +102 -102
  52. package/docs/05-domain/deployment-template.md +76 -76
  53. package/docs/05-domain/environment-template.md +165 -165
  54. package/docs/05-domain/operation-binding-template.md +55 -55
  55. package/docs/05-domain/operation-record-template.md +55 -55
  56. package/docs/05-domain/prompt-template.md +90 -90
  57. package/docs/05-domain/rule-template.md +73 -73
  58. package/docs/05-domain/service-template.md +39 -39
  59. package/docs/06-operations/deployment-guide.md +54 -54
  60. package/docs/06-operations/release.md +198 -188
  61. package/docs/06-operations/security-policy.md +53 -53
  62. package/docs/06-operations/troubleshooting.md +141 -91
  63. package/docs/07-templates/adr-template.md +21 -21
  64. package/docs/07-templates/bugfix-template.md +11 -11
  65. package/docs/07-templates/case-template.md +15 -15
  66. package/docs/07-templates/design-template.md +29 -29
  67. package/docs/07-templates/proposal-template.md +19 -19
  68. package/docs/07-templates/spec-template.md +15 -15
  69. package/docs/07-templates/tasks-template.md +12 -12
  70. package/docs/99-archive/README.md +13 -13
  71. package/docs/README.md +142 -142
  72. package/icon.svg +4 -4
  73. package/index.js +31 -8
  74. package/lib/skill.js +37 -37
  75. package/locale/en.json +6 -6
  76. package/locale/zh.json +6 -6
  77. package/package.json +101 -99
  78. package/scripts/repair-profile.mjs +141 -0
@@ -1,91 +1,141 @@
1
- # Troubleshooting
2
-
3
- ## Plugin is not visible after install
4
-
5
- 1. Ask `plugin_manager` for `action: list_bundles` — confirm the bundle is listed.
6
- 2. Check the activation result for `failed` / `overridden` / `restart-required`.
7
- 3. Restart DSH.
8
-
9
- ## Host build fails
10
-
11
- 1. Run `npm run build` and read the first error, not the count.
12
- 2. Confirm `tsconfig.json` exists and `outDir` is `lib`.
13
- 3. Check that `index.js` re-exports `./lib/index.js` and the file exists.
14
-
15
- ## Tools are not registered
16
-
17
- 1. Confirm the bundle is active.
18
- 2. Check Host logs for an exception in `apply`.
19
- 3. Call `env_list`: an empty list is correct on a fresh install; an unknown tool means registration failed.
20
- 4. Reinstall after every Host rebuild; Host code changes need a fresh module generation.
21
-
22
- ## Client panel does not appear
23
-
24
- 1. Verify `client.js` is listed in `files` and exported as `./client`.
25
- 2. Check the browser console for module-loader errors.
26
- 3. Verify the slot id and name match a live slot.
27
- 4. Reinstall the bundle after editing `client.js`.
28
-
29
- ## Registry loads with warnings
30
-
31
- Warnings are expected when a file is invalid. They name the file and the field.
32
-
33
- 1. Fix the YAML or the field.
34
- 2. Run `env_validate` again.
35
- 3. Invalid files are never deleted automatically, so the data is still on disk.
36
-
37
- ## `env_resolve` returns `RULE_UNDEFINED_VARIABLE`
38
-
39
- 1. The message names the field and the missing variable.
40
- 2. Check that the variable exists in a referenced rule profile or in an environment/deployment override.
41
- 3. Remember that only the deployment's runtime fields are in scope.
42
-
43
- ## `RULE_CYCLE`
44
-
45
- Two or more fields reference each other. Break the cycle in the rule profile; the message contains the cycle path.
46
-
47
- ## `RULE_PATH_TRAVERSAL`
48
-
49
- A resolved path contains a `..` segment. Fix the template; traversal is rejected by design.
50
-
51
- ## `DEPLOYMENT_AMBIGUOUS`
52
-
53
- The service has several bindings in the environment. Pass `deploymentId` explicitly.
54
-
55
- ## `BINDING_CONFLICT`
56
-
57
- Two enabled bindings match at the same level. Disable one, narrow one, or merge them. The plugin will not choose for you.
58
-
59
- ## `SKILL_UNAVAILABLE`
60
-
61
- The bound Skill is not registered, or its source/provider does not match. Install or correct the Skill; do not add a fallback binding that changes the environment silently.
62
-
63
- ## `POLICY_DENIED`
64
-
65
- Either the environment is production and the binding does not allow it, or an approval was denied. Fix the policy deliberately, not by flipping flags in a hurry.
66
-
67
- ## Session default is not remembered
68
-
69
- If the tool reports `persisted: false`, the state file could not be written. Check `dataDir` permissions and the `sessions/` directory. The value is kept in a process-local cache, so it still works for this process but is lost on restart.
70
-
71
- ## Panel says "Cannot reach the Host"
72
-
73
- 1. Confirm the bundle is active and the Host is running.
74
- 2. Reload the page; the panel uses a same-origin `POST /env-manager/api`.
75
- 3. In the browser console, a 403 means the request header or origin check failed — this is the transport control, not a bug.
76
- 4. A 404 means the route was not registered; reinstall the bundle after a Host rebuild.
77
-
78
- ## Panel write is denied for a production record
79
-
80
- `writePolicy.allowUiProductionWrites` defaults to `false`. Edit the YAML through the Agent (`env_save`, with approval) or change the policy deliberately.
81
-
82
- ## Panel shows "Unknown" skill availability
83
-
84
- The Skill catalog was absent or incomplete when the operation was resolved. Check that the Skill registry is available; the router never assumes a missing catalog means "available".
85
-
86
- ## Storage errors
87
-
88
- 1. Verify write permission on `dataDir`.
89
- 2. Check that `dataDir` is not inside a read-only workspace.
90
- 3. Confirm the file name matches the record `id`.
91
- 4. Check `schemaVersion`; V1 only reads `1`.
1
+ # Troubleshooting
2
+
3
+ ## Install fails with "Cannot find module .../lib/index.js"
4
+
5
+ This means DSH found the bundle but the Host build output was absent or incomplete.
6
+
7
+ 1. Prefer the published package: `plugin_manager` → `install_bundle` with
8
+ `dsh-env-manager-plugin@0.1.1`. The npm tarball includes `lib/`.
9
+ 2. If installing a local checkout, use the current `main`; `lib/` is committed there on
10
+ purpose. Older clones did not include it.
11
+ 3. If the checkout is older or `lib/` was deleted, run `npm install && npm run build`
12
+ in the repository, then reinstall the bundle.
13
+ 4. Do not copy only `index.js` into a profile; the bundle needs `lib/`, `client.js`,
14
+ `cordis.patch.yml` and the locale files together.
15
+
16
+ `index.js` now reports this condition with a dedicated message instead of a bare
17
+ `ERR_MODULE_NOT_FOUND`.
18
+
19
+ ## DSH does not start: duplicate bundle registration
20
+
21
+ The plugin must appear **once** in the profile. A failed manual install often leaves both
22
+ an old `dsh-env-manager` entry and a new `dsh-env-manager-plugin` entry, which inserts the
23
+ same loader row twice.
24
+
25
+ For the affected profile, stop DSH, back up both files, and inspect:
26
+
27
+ ```powershell
28
+ $p = Join-Path $HOME '.dsh\profiles\<profile>'
29
+ Get-Content -Raw (Join-Path $p 'package.json')
30
+ Get-ChildItem (Join-Path $p 'node_modules') | Where-Object Name -match 'env-manager'
31
+ ```
32
+
33
+ In `package.json`:
34
+
35
+ - keep `dsh-env-manager-plugin` exactly once in `dependencies`;
36
+ - keep `dsh-env-manager-plugin` exactly once in `dsh.profile.bundles`;
37
+ - remove the legacy `dsh-env-manager` dependency and bundle entry;
38
+ - do not add a second bundle entry by hand.
39
+
40
+ Then remove any stale `node_modules/dsh-env-manager` link and reinstall through
41
+ `plugin_manager`. Do not copy files into the profile as a workaround.
42
+
43
+ From a checkout you can run the repair helper before restarting:
44
+
45
+ ```powershell
46
+ node scripts/repair-profile.mjs --profile <profile>
47
+ node scripts/repair-profile.mjs --profile <profile> --fix
48
+ ```
49
+
50
+ The helper edits only `package.json` (with a timestamped backup); it never deletes
51
+ registry data. It lives in the repository and in `dsh-env-manager-plugin@0.1.1`+.
52
+
53
+ ## Plugin is not visible after install
54
+
55
+ 1. Ask `plugin_manager` for `action: list_bundles` — confirm the bundle is listed.
56
+ 2. Check the activation result for `failed` / `overridden` / `restart-required`.
57
+ 3. Restart DSH.
58
+
59
+ ## Host build fails
60
+
61
+ 1. Run `npm run build` and read the first error, not the count.
62
+ 2. Confirm `tsconfig.json` exists and `outDir` is `lib`.
63
+ 3. Check that `index.js` re-exports `./lib/index.js` and the file exists.
64
+
65
+ ## Tools are not registered
66
+
67
+ 1. Confirm the bundle is active.
68
+ 2. Check Host logs for an exception in `apply`.
69
+ 3. Call `env_list`: an empty list is correct on a fresh install; an unknown tool means registration failed.
70
+ 4. Reinstall after every Host rebuild; Host code changes need a fresh module generation.
71
+
72
+ ## Client panel does not appear
73
+
74
+ 1. Verify `client.js` is listed in `files` and exported as `./client`.
75
+ 2. Check the browser console for module-loader errors.
76
+ 3. Verify the slot id and name match a live slot.
77
+ 4. Reinstall the bundle after editing `client.js`.
78
+
79
+ ## Registry loads with warnings
80
+
81
+ Warnings are expected when a file is invalid. They name the file and the field.
82
+
83
+ 1. Fix the YAML or the field.
84
+ 2. Run `env_validate` again.
85
+ 3. Invalid files are never deleted automatically, so the data is still on disk.
86
+
87
+ ## `env_resolve` returns `RULE_UNDEFINED_VARIABLE`
88
+
89
+ 1. The message names the field and the missing variable.
90
+ 2. Check that the variable exists in a referenced rule profile or in an environment/deployment override.
91
+ 3. Remember that only the deployment's runtime fields are in scope.
92
+
93
+ ## `RULE_CYCLE`
94
+
95
+ Two or more fields reference each other. Break the cycle in the rule profile; the message contains the cycle path.
96
+
97
+ ## `RULE_PATH_TRAVERSAL`
98
+
99
+ A resolved path contains a `..` segment. Fix the template; traversal is rejected by design.
100
+
101
+ ## `DEPLOYMENT_AMBIGUOUS`
102
+
103
+ The service has several bindings in the environment. Pass `deploymentId` explicitly.
104
+
105
+ ## `BINDING_CONFLICT`
106
+
107
+ Two enabled bindings match at the same level. Disable one, narrow one, or merge them. The plugin will not choose for you.
108
+
109
+ ## `SKILL_UNAVAILABLE`
110
+
111
+ The bound Skill is not registered, or its source/provider does not match. Install or correct the Skill; do not add a fallback binding that changes the environment silently.
112
+
113
+ ## `POLICY_DENIED`
114
+
115
+ Either the environment is production and the binding does not allow it, or an approval was denied. Fix the policy deliberately, not by flipping flags in a hurry.
116
+
117
+ ## Session default is not remembered
118
+
119
+ If the tool reports `persisted: false`, the state file could not be written. Check `dataDir` permissions and the `sessions/` directory. The value is kept in a process-local cache, so it still works for this process but is lost on restart.
120
+
121
+ ## Panel says "Cannot reach the Host"
122
+
123
+ 1. Confirm the bundle is active and the Host is running.
124
+ 2. Reload the page; the panel uses a same-origin `POST /env-manager/api`.
125
+ 3. In the browser console, a 403 means the request header or origin check failed — this is the transport control, not a bug.
126
+ 4. A 404 means the route was not registered; reinstall the bundle after a Host rebuild.
127
+
128
+ ## Panel write is denied for a production record
129
+
130
+ `writePolicy.allowUiProductionWrites` defaults to `false`. Edit the YAML through the Agent (`env_save`, with approval) or change the policy deliberately.
131
+
132
+ ## Panel shows "Unknown" skill availability
133
+
134
+ The Skill catalog was absent or incomplete when the operation was resolved. Check that the Skill registry is available; the router never assumes a missing catalog means "available".
135
+
136
+ ## Storage errors
137
+
138
+ 1. Verify write permission on `dataDir`.
139
+ 2. Check that `dataDir` is not inside a read-only workspace.
140
+ 3. Confirm the file name matches the record `id`.
141
+ 4. Check `schemaVersion`; V1 only reads `1`.
@@ -1,21 +1,21 @@
1
- # ADR-{NNNN}: Title
2
-
3
- ## Status
4
-
5
- Proposed / Accepted / Superseded
6
-
7
- ## Context
8
-
9
- What is the issue that we're seeing that is motivating this decision?
10
-
11
- ## Decision
12
-
13
- What is the change that we're proposing or have accepted?
14
-
15
- ## Consequences
16
-
17
- What becomes easier or more difficult to do because of this change?
18
-
19
- ## Alternatives Considered
20
-
21
- What other approaches were considered and why were they rejected?
1
+ # ADR-{NNNN}: Title
2
+
3
+ ## Status
4
+
5
+ Proposed / Accepted / Superseded
6
+
7
+ ## Context
8
+
9
+ What is the issue that we're seeing that is motivating this decision?
10
+
11
+ ## Decision
12
+
13
+ What is the change that we're proposing or have accepted?
14
+
15
+ ## Consequences
16
+
17
+ What becomes easier or more difficult to do because of this change?
18
+
19
+ ## Alternatives Considered
20
+
21
+ What other approaches were considered and why were they rejected?
@@ -1,11 +1,11 @@
1
- # Bugfix: {Name}
2
-
3
- ## Symptom
4
-
5
- ## Root Cause
6
-
7
- ## Fix
8
-
9
- ## Regression Test
10
-
11
- ## Verification
1
+ # Bugfix: {Name}
2
+
3
+ ## Symptom
4
+
5
+ ## Root Cause
6
+
7
+ ## Fix
8
+
9
+ ## Regression Test
10
+
11
+ ## Verification
@@ -1,15 +1,15 @@
1
- # Case: {Name}
2
-
3
- ## Environment
4
-
5
- ## Service
6
-
7
- ## Operation
8
-
9
- ## Expected Behavior
10
-
11
- ## Actual Behavior
12
-
13
- ## Resolution
14
-
15
- ## Lessons Learned
1
+ # Case: {Name}
2
+
3
+ ## Environment
4
+
5
+ ## Service
6
+
7
+ ## Operation
8
+
9
+ ## Expected Behavior
10
+
11
+ ## Actual Behavior
12
+
13
+ ## Resolution
14
+
15
+ ## Lessons Learned
@@ -1,29 +1,29 @@
1
- # Design: {Name}
2
-
3
- ## Overview
4
-
5
- What is being designed and why.
6
-
7
- ## Data Flow
8
-
9
- Step-by-step flow.
10
-
11
- ## Module Allocation
12
-
13
- Which modules are involved and what each owns.
14
-
15
- ## Schema Changes
16
-
17
- New or changed YAML/JSON schemas.
18
-
19
- ## Security Considerations
20
-
21
- Credential handling, approval policies, production access.
22
-
23
- ## Error Handling
24
-
25
- Expected failure modes and responses.
26
-
27
- ## Verification Plan
28
-
29
- Tests and manual checks.
1
+ # Design: {Name}
2
+
3
+ ## Overview
4
+
5
+ What is being designed and why.
6
+
7
+ ## Data Flow
8
+
9
+ Step-by-step flow.
10
+
11
+ ## Module Allocation
12
+
13
+ Which modules are involved and what each owns.
14
+
15
+ ## Schema Changes
16
+
17
+ New or changed YAML/JSON schemas.
18
+
19
+ ## Security Considerations
20
+
21
+ Credential handling, approval policies, production access.
22
+
23
+ ## Error Handling
24
+
25
+ Expected failure modes and responses.
26
+
27
+ ## Verification Plan
28
+
29
+ Tests and manual checks.
@@ -1,19 +1,19 @@
1
- # Proposal: {Name}
2
-
3
- ## Problem
4
-
5
- ## Goal
6
-
7
- ## Scope
8
-
9
- ## Out of Scope
10
-
11
- ## Affected Modules
12
-
13
- ## Storage Impact
14
-
15
- ## Constraints
16
-
17
- ## Risks
18
-
19
- ## Verification
1
+ # Proposal: {Name}
2
+
3
+ ## Problem
4
+
5
+ ## Goal
6
+
7
+ ## Scope
8
+
9
+ ## Out of Scope
10
+
11
+ ## Affected Modules
12
+
13
+ ## Storage Impact
14
+
15
+ ## Constraints
16
+
17
+ ## Risks
18
+
19
+ ## Verification
@@ -1,15 +1,15 @@
1
- # Spec: {Name}
2
-
3
- ## Objectives
4
-
5
- ## Functional Requirements
6
-
7
- ## Non-functional Requirements
8
-
9
- ## Interface Definitions
10
-
11
- ## Data Definitions
12
-
13
- ## Acceptance Criteria
14
-
15
- ## Open Questions
1
+ # Spec: {Name}
2
+
3
+ ## Objectives
4
+
5
+ ## Functional Requirements
6
+
7
+ ## Non-functional Requirements
8
+
9
+ ## Interface Definitions
10
+
11
+ ## Data Definitions
12
+
13
+ ## Acceptance Criteria
14
+
15
+ ## Open Questions
@@ -1,12 +1,12 @@
1
- # Tasks: {Name}
2
-
3
- - [ ] Task 1
4
- - Files:
5
- - Behavior:
6
- - Tests:
7
- - Verification:
8
- - [ ] Task 2
9
- - Files:
10
- - Behavior:
11
- - Tests:
12
- - Verification:
1
+ # Tasks: {Name}
2
+
3
+ - [ ] Task 1
4
+ - Files:
5
+ - Behavior:
6
+ - Tests:
7
+ - Verification:
8
+ - [ ] Task 2
9
+ - Files:
10
+ - Behavior:
11
+ - Tests:
12
+ - Verification:
@@ -1,13 +1,13 @@
1
- # Archive
2
-
3
- This directory contains obsolete or historical documents.
4
-
5
- Do not rely on archived documents for current decisions.
6
-
7
- ## Naming
8
-
9
- Prefix files with date:
10
-
11
- ```text
12
- docs/99-archive/YYYY-MM-DD-title.md
13
- ```
1
+ # Archive
2
+
3
+ This directory contains obsolete or historical documents.
4
+
5
+ Do not rely on archived documents for current decisions.
6
+
7
+ ## Naming
8
+
9
+ Prefix files with date:
10
+
11
+ ```text
12
+ docs/99-archive/YYYY-MM-DD-title.md
13
+ ```