dsh-env-manager-plugin 0.1.0 → 0.1.2

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 (81) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +274 -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/app/app.d.ts +1 -1
  75. package/lib/app/app.js +4 -1
  76. package/lib/app/app.js.map +1 -1
  77. package/lib/skill.js +37 -37
  78. package/locale/en.json +6 -6
  79. package/locale/zh.json +6 -6
  80. package/package.json +101 -99
  81. package/scripts/repair-profile.mjs +141 -0
@@ -1,55 +1,61 @@
1
- # Local Run Guide
2
-
3
- ## Build
4
-
5
- ```bash
6
- npm install
7
- npm run build
8
- ```
9
-
10
- ## Install in a DSH Profile
11
-
12
- In a DSH session, call the `plugin_manager` tool:
13
-
14
- ```text
15
- action: install_bundle
16
- target: <absolute path to this repository>
17
- ```
18
-
19
- Restart DSH if the bundle was already installed before this change.
20
-
21
- ## Verify Installation
22
-
23
- Ask `plugin_manager` for `action: list_bundles`, then confirm the bundle appears.
24
-
25
- Then check that the tools are available: ask the Agent to call `env_list`; it should return an empty list rather than an unknown-tool error.
26
-
27
- ## Where the data lives
28
-
29
- The Host reports the resolved `dataDir` once at startup. On first run the directories are created:
30
-
31
- ```text
32
- <dataDir>/environments services deployments rules operations sessions
33
- ```
34
-
35
- Put a sample environment there or use `env_save`.
36
-
37
- ## Development loop
38
-
39
- 1. Edit `src/`.
40
- 2. `npm run build`.
41
- 3. Reinstall the bundle.
42
- 4. Restart DSH (Host code changes need a fresh module generation).
43
- 5. Call the tool again.
44
-
45
- `client.js` changes need the same reinstall; they do not require a build.
46
-
47
- ## Uninstall
48
-
49
- Call `plugin_manager` with `action: remove_bundle` and `target: dsh-env-manager-plugin`.
50
-
51
- Registry data under `dataDir` is not removed automatically. Back it up before deleting the profile.
52
-
53
- ## Troubleshooting
54
-
55
- See `06-operations/troubleshooting.md`.
1
+ # Local Run Guide
2
+
3
+ ## Build
4
+
5
+ The repository commits the compiled `lib/` directory, so a fresh checkout is installable
6
+ without a build. Rebuild only after changing `src/`:
7
+
8
+ ```bash
9
+ npm install
10
+ npm run build
11
+ ```
12
+
13
+ ## Install in a DSH Profile
14
+
15
+ In a DSH session, call the `plugin_manager` tool:
16
+
17
+ ```text
18
+ action: install_bundle
19
+ target: <absolute path to this repository>
20
+ ```
21
+
22
+ The install is one bundle entry. Do not also edit `dsh.profile.bundles` by hand; a second
23
+ entry loads the plugin twice and prevents DSH from starting.
24
+
25
+ Restart DSH if the bundle was already installed before this change.
26
+
27
+ ## Verify Installation
28
+
29
+ Ask `plugin_manager` for `action: list_bundles`, then confirm the bundle appears.
30
+
31
+ Then check that the tools are available: ask the Agent to call `env_list`; it should return an empty list rather than an unknown-tool error.
32
+
33
+ ## Where the data lives
34
+
35
+ The Host reports the resolved `dataDir` once at startup. On first run the directories are created:
36
+
37
+ ```text
38
+ <dataDir>/environments services deployments rules operations sessions
39
+ ```
40
+
41
+ Put a sample environment there or use `env_save`.
42
+
43
+ ## Development loop
44
+
45
+ 1. Edit `src/`.
46
+ 2. `npm run build`.
47
+ 3. Reinstall the bundle.
48
+ 4. Restart DSH (Host code changes need a fresh module generation).
49
+ 5. Call the tool again.
50
+
51
+ `client.js` changes need the same reinstall; they do not require a build.
52
+
53
+ ## Uninstall
54
+
55
+ Call `plugin_manager` with `action: remove_bundle` and `target: dsh-env-manager-plugin`.
56
+
57
+ Registry data under `dataDir` is not removed automatically. Back it up before deleting the profile.
58
+
59
+ ## Troubleshooting
60
+
61
+ See `06-operations/troubleshooting.md`.
@@ -1,102 +1,102 @@
1
- # Testing Guide
2
-
3
- ## Framework
4
-
5
- Vitest, with TypeScript sources tested directly (no build required for tests).
6
-
7
- ## Commands
8
-
9
- ```bash
10
- npm test # run once
11
- npm run test:watch # watch mode
12
- ```
13
-
14
- ## Test Organization
15
-
16
- ```text
17
- tests/
18
- ├── domain/schemas.test.ts
19
- ├── storage/records.test.ts
20
- ├── storage/atomic.test.ts
21
- ├── registry/registry.test.ts
22
- ├── resolver/template.test.ts
23
- ├── resolver/layers.test.ts
24
- ├── resolver/context.test.ts
25
- ├── router/match.test.ts
26
- ├── router/router.test.ts
27
- ├── session/session-context.test.ts
28
- ├── app/app.test.ts
29
- ├── tools/read.test.ts
30
- ├── tools/write.test.ts
31
- └── http/route.test.ts
32
- ```
33
-
34
- ## What to test
35
-
36
- ### `domain`
37
- - Valid record passes; unknown field fails.
38
- - Id pattern and `schemaVersion` enforcement.
39
- - Discriminated unions reject mismatched `runtimeMode`/`location.kind`.
40
-
41
- ### `storage`
42
- - Atomic write leaves no temp file.
43
- - Read tolerates missing directory and invalid YAML.
44
- - Backup pruning keeps at most 5.
45
- - Concurrent writes serialize in-process.
46
-
47
- ### `registry`
48
- - Load, lookup by id and alias.
49
- - Duplicate id detection.
50
- - Referential integrity: missing environment/service/host/cluster/rule profile.
51
- - Invalid file is skipped, not deleted.
52
-
53
- ### `resolver`
54
- - Layer precedence: service < environment < deployment.
55
- - Field-level merge keeps unrelated fields.
56
- - Provenance: `definedBy`, `inputs`, `shadowed` for the worked example in design §6.9.
57
- - Undefined variable, cycle, path traversal, type mismatch.
58
- - Only the runtime's log source and class location are resolved.
59
-
60
- ### `router`
61
- - Each match level, in isolation and in combination.
62
- - Highest level wins; lower levels ignored.
63
- - Same-level conflict lists all candidates and selects none.
64
- - Missing skill, source mismatch, provider mismatch.
65
- - Unknown/incomplete skill registry degrades to `'unknown'` plus warning.
66
- - Production denial and `requiresApproval` defaults.
67
- - Parameter mapping, including failure on unresolved reference.
68
-
69
- ### `session`
70
- - Set, get, clear.
71
- - Two sessions do not interfere.
72
- - Corrupt file is treated as "no default" with `persisted: false`.
73
-
74
- ### `app`
75
- - Save→get round trip; `created` flag.
76
- - Delete refused when referenced (`RECORD_IN_USE`).
77
- - Dry-run writes nothing.
78
- - UI actor cannot write production by default.
79
- - `find` matches id, name and alias.
80
-
81
- ### `tools`
82
- - Success value matches the declared `output.schema`.
83
- - Failures throw `EnvManagerError` with the expected code.
84
- - No credential value ever appears in output (assert on serialized JSON).
85
- - Invalid id error code.
86
- - `env_validate` does not write.
87
- - Approval denial produces `POLICY_DENIED` and no file change.
88
-
89
- ### `http`
90
- - Missing header → 403; foreign origin → 403; GET → 405; oversize → 413.
91
- - Unknown op → 400; not found → 404; conflict → 409; production UI write → 403.
92
- - Success envelope is `{ ok: true, data }` and never leaks a stack.
93
-
94
- ## Fixtures
95
-
96
- - Under `tests/fixtures/`, one directory per scenario.
97
- - Fake values only: `test-a`, `10.0.0.x`, `example.internal`, `cred-test-*`.
98
- - A fixture that needs a secret-like string must use an obvious placeholder and must not be a real credential.
99
-
100
- ## Coverage expectations
101
-
102
- No numeric gate in V1. The resolver, router and storage modules are expected to be near-complete because they are pure and cheap to test. The Client UI is verified manually.
1
+ # Testing Guide
2
+
3
+ ## Framework
4
+
5
+ Vitest, with TypeScript sources tested directly (no build required for tests).
6
+
7
+ ## Commands
8
+
9
+ ```bash
10
+ npm test # run once
11
+ npm run test:watch # watch mode
12
+ ```
13
+
14
+ ## Test Organization
15
+
16
+ ```text
17
+ tests/
18
+ ├── domain/schemas.test.ts
19
+ ├── storage/records.test.ts
20
+ ├── storage/atomic.test.ts
21
+ ├── registry/registry.test.ts
22
+ ├── resolver/template.test.ts
23
+ ├── resolver/layers.test.ts
24
+ ├── resolver/context.test.ts
25
+ ├── router/match.test.ts
26
+ ├── router/router.test.ts
27
+ ├── session/session-context.test.ts
28
+ ├── app/app.test.ts
29
+ ├── tools/read.test.ts
30
+ ├── tools/write.test.ts
31
+ └── http/route.test.ts
32
+ ```
33
+
34
+ ## What to test
35
+
36
+ ### `domain`
37
+ - Valid record passes; unknown field fails.
38
+ - Id pattern and `schemaVersion` enforcement.
39
+ - Discriminated unions reject mismatched `runtimeMode`/`location.kind`.
40
+
41
+ ### `storage`
42
+ - Atomic write leaves no temp file.
43
+ - Read tolerates missing directory and invalid YAML.
44
+ - Backup pruning keeps at most 5.
45
+ - Concurrent writes serialize in-process.
46
+
47
+ ### `registry`
48
+ - Load, lookup by id and alias.
49
+ - Duplicate id detection.
50
+ - Referential integrity: missing environment/service/host/cluster/rule profile.
51
+ - Invalid file is skipped, not deleted.
52
+
53
+ ### `resolver`
54
+ - Layer precedence: service < environment < deployment.
55
+ - Field-level merge keeps unrelated fields.
56
+ - Provenance: `definedBy`, `inputs`, `shadowed` for the worked example in design §6.9.
57
+ - Undefined variable, cycle, path traversal, type mismatch.
58
+ - Only the runtime's log source and class location are resolved.
59
+
60
+ ### `router`
61
+ - Each match level, in isolation and in combination.
62
+ - Highest level wins; lower levels ignored.
63
+ - Same-level conflict lists all candidates and selects none.
64
+ - Missing skill, source mismatch, provider mismatch.
65
+ - Unknown/incomplete skill registry degrades to `'unknown'` plus warning.
66
+ - Production denial and `requiresApproval` defaults.
67
+ - Parameter mapping, including failure on unresolved reference.
68
+
69
+ ### `session`
70
+ - Set, get, clear.
71
+ - Two sessions do not interfere.
72
+ - Corrupt file is treated as "no default" with `persisted: false`.
73
+
74
+ ### `app`
75
+ - Save→get round trip; `created` flag.
76
+ - Delete refused when referenced (`RECORD_IN_USE`).
77
+ - Dry-run writes nothing.
78
+ - UI actor cannot write production by default.
79
+ - `find` matches id, name and alias.
80
+
81
+ ### `tools`
82
+ - Success value matches the declared `output.schema`.
83
+ - Failures throw `EnvManagerError` with the expected code.
84
+ - No credential value ever appears in output (assert on serialized JSON).
85
+ - Invalid id error code.
86
+ - `env_validate` does not write.
87
+ - Approval denial produces `POLICY_DENIED` and no file change.
88
+
89
+ ### `http`
90
+ - Missing header → 403; foreign origin → 403; GET → 405; oversize → 413.
91
+ - Unknown op → 400; not found → 404; conflict → 409; production UI write → 403.
92
+ - Success envelope is `{ ok: true, data }` and never leaks a stack.
93
+
94
+ ## Fixtures
95
+
96
+ - Under `tests/fixtures/`, one directory per scenario.
97
+ - Fake values only: `test-a`, `10.0.0.x`, `example.internal`, `cred-test-*`.
98
+ - A fixture that needs a secret-like string must use an obvious placeholder and must not be a real credential.
99
+
100
+ ## Coverage expectations
101
+
102
+ No numeric gate in V1. The resolver, router and storage modules are expected to be near-complete because they are pure and cheap to test. The Client UI is verified manually.
@@ -1,76 +1,76 @@
1
- # Deployment Binding Template
2
-
3
- Copy into `<dataDir>/deployments/<id>.yaml`.
4
-
5
- A service may have several bindings in one environment. Use distinct ids and a `name` to tell them apart.
6
-
7
- ## Kubernetes
8
-
9
- ```yaml
10
- id: deploy-001
11
- schemaVersion: 1
12
- name: aicoservice-test-a
13
- environmentId: test-a
14
- serviceId: aicoservice
15
- runtimeMode: kubernetes
16
- location:
17
- kind: kubernetes
18
- clusterRef: k8s-01
19
- namespace: dv-sop
20
- workload:
21
- kind: Deployment
22
- name: aicoservice
23
- container: aicoservice
24
- variables:
25
- replicaCount: 2
26
- ruleOverrides:
27
- logSources:
28
- kubernetes:
29
- kind: pod-logs
30
- namespace: dv-sop
31
- workload: aicoservice
32
- createdAt: 2026-11-01T03:00:00.000Z
33
- updatedAt: 2026-11-01T03:00:00.000Z
34
- ```
35
-
36
- ## Native
37
-
38
- ```yaml
39
- id: deploy-002
40
- schemaVersion: 1
41
- environmentId: test-a
42
- serviceId: aicoservice
43
- runtimeMode: native
44
- location:
45
- kind: native
46
- hostRef: host-001
47
- installDir: /opt/company/services/aicoservice
48
- serviceName: aicoservice.service
49
- createdAt: 2026-11-01T03:00:00.000Z
50
- updatedAt: 2026-11-01T03:00:00.000Z
51
- ```
52
-
53
- ## Docker
54
-
55
- ```yaml
56
- id: deploy-003
57
- schemaVersion: 1
58
- environmentId: test-a
59
- serviceId: aicoservice
60
- runtimeMode: docker
61
- location:
62
- kind: docker
63
- hostRef: host-001
64
- containerName: aicoservice
65
- image: registry.example.internal/team/aicoservice:latest
66
- createdAt: 2026-11-01T03:00:00.000Z
67
- updatedAt: 2026-11-01T03:00:00.000Z
68
- ```
69
-
70
- ## Notes
71
-
72
- - `runtimeMode` must equal `location.kind`.
73
- - `hostRef` and `clusterRef` resolve inside the referenced environment only.
74
- - `variables` are deployment-level user variables; they win over environment-level variables for that field.
75
- - `ruleOverrides` is field-level: overriding `logSources` does not erase `paths`.
76
- - If a service has several bindings and the caller omits `deploymentId`, the resolver fails with `DEPLOYMENT_AMBIGUOUS` rather than guessing.
1
+ # Deployment Binding Template
2
+
3
+ Copy into `<dataDir>/deployments/<id>.yaml`.
4
+
5
+ A service may have several bindings in one environment. Use distinct ids and a `name` to tell them apart.
6
+
7
+ ## Kubernetes
8
+
9
+ ```yaml
10
+ id: deploy-001
11
+ schemaVersion: 1
12
+ name: aicoservice-test-a
13
+ environmentId: test-a
14
+ serviceId: aicoservice
15
+ runtimeMode: kubernetes
16
+ location:
17
+ kind: kubernetes
18
+ clusterRef: k8s-01
19
+ namespace: dv-sop
20
+ workload:
21
+ kind: Deployment
22
+ name: aicoservice
23
+ container: aicoservice
24
+ variables:
25
+ replicaCount: 2
26
+ ruleOverrides:
27
+ logSources:
28
+ kubernetes:
29
+ kind: pod-logs
30
+ namespace: dv-sop
31
+ workload: aicoservice
32
+ createdAt: 2026-11-01T03:00:00.000Z
33
+ updatedAt: 2026-11-01T03:00:00.000Z
34
+ ```
35
+
36
+ ## Native
37
+
38
+ ```yaml
39
+ id: deploy-002
40
+ schemaVersion: 1
41
+ environmentId: test-a
42
+ serviceId: aicoservice
43
+ runtimeMode: native
44
+ location:
45
+ kind: native
46
+ hostRef: host-001
47
+ installDir: /opt/company/services/aicoservice
48
+ serviceName: aicoservice.service
49
+ createdAt: 2026-11-01T03:00:00.000Z
50
+ updatedAt: 2026-11-01T03:00:00.000Z
51
+ ```
52
+
53
+ ## Docker
54
+
55
+ ```yaml
56
+ id: deploy-003
57
+ schemaVersion: 1
58
+ environmentId: test-a
59
+ serviceId: aicoservice
60
+ runtimeMode: docker
61
+ location:
62
+ kind: docker
63
+ hostRef: host-001
64
+ containerName: aicoservice
65
+ image: registry.example.internal/team/aicoservice:latest
66
+ createdAt: 2026-11-01T03:00:00.000Z
67
+ updatedAt: 2026-11-01T03:00:00.000Z
68
+ ```
69
+
70
+ ## Notes
71
+
72
+ - `runtimeMode` must equal `location.kind`.
73
+ - `hostRef` and `clusterRef` resolve inside the referenced environment only.
74
+ - `variables` are deployment-level user variables; they win over environment-level variables for that field.
75
+ - `ruleOverrides` is field-level: overriding `logSources` does not erase `paths`.
76
+ - If a service has several bindings and the caller omits `deploymentId`, the resolver fails with `DEPLOYMENT_AMBIGUOUS` rather than guessing.