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
@@ -0,0 +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.
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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:
@@ -0,0 +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
+ ```
package/docs/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # DSH Environment Manager Docs
2
+
3
+ This directory is the **project-level Harness Context Hub** for the DSH Environment Manager plugin.
4
+
5
+ It is used by humans and AI agents to understand project state, architecture, constraints, development standards, and operational procedures.
6
+
7
+ ## Reading Policy
8
+
9
+ Do not read every document blindly. Read documents based on task type.
10
+
11
+ ### Required for Every Non-trivial Change
12
+
13
+ 1. `AGENTS.md` at the repository root
14
+ 2. `docs/00-project/project-brief.md`
15
+ 3. `docs/00-project/current-state.md`
16
+ 4. `docs/02-harness/harness-standard.md`
17
+ 5. `docs/04-development/development-guide.md`
18
+
19
+ ### Architecture or Schema Changes
20
+
21
+ Also read:
22
+
23
+ 1. `docs/01-architecture/design.md`
24
+ 2. `docs/01-architecture/data-model.md`
25
+ 3. `docs/01-architecture/detailed-design.md`
26
+ 4. `docs/01-architecture/module-boundaries.md`
27
+ 5. `docs/01-architecture/storage-contract.md`
28
+
29
+ ### Environment Model Questions
30
+
31
+ Also read:
32
+
33
+ 1. `docs/01-architecture/decisions/ADR-0010-environment-plane-model.md`
34
+ 2. `docs/01-architecture/decisions/ADR-0011-k8s-node-execution-model.md`
35
+ 3. `docs/01-architecture/data-model.md` §3
36
+ 4. `docs/01-architecture/ui-design.md` §6.3
37
+
38
+ ### Runtime API Questions
39
+
40
+ Also read:
41
+
42
+ 1. `docs/01-architecture/api-verification.md`
43
+ 2. `docs/01-architecture/decisions/ADR-0009-client-host-http-transport.md`
44
+
45
+ ### Implementation Work
46
+
47
+ Also read:
48
+
49
+ 1. `docs/01-architecture/implementation-plan.md`
50
+ 2. `docs/01-architecture/ui-design.md` (Client changes only)
51
+ 3. `docs/02-harness/client-ui-integration.md` (sidebar/main slot changes only)
52
+
53
+ ### Tool Surface Changes
54
+
55
+ Also read:
56
+
57
+ 1. `docs/01-architecture/tool-contract.md`
58
+ 2. `docs/01-architecture/data-model.md`
59
+ 3. `docs/01-architecture/detailed-design.md` §11
60
+
61
+ ### Resolver / Rule Work
62
+
63
+ Also read:
64
+
65
+ 1. `docs/01-architecture/design.md` §6
66
+ 2. `docs/05-domain/rule-template.md`
67
+ 3. `docs/01-architecture/decisions/ADR-0005-layered-rule-resolution.md`
68
+
69
+ ### Router / Skill Binding Work
70
+
71
+ Also read:
72
+
73
+ 1. `docs/01-architecture/design.md` §7
74
+ 2. `docs/05-domain/operation-binding-template.md`
75
+ 3. `docs/01-architecture/decisions/ADR-0003-skill-router-over-search.md`
76
+
77
+ ### Security-Sensitive Work
78
+
79
+ Also read:
80
+
81
+ 1. `docs/01-architecture/security-model.md`
82
+ 2. `docs/06-operations/security-policy.md`
83
+
84
+ ### Deployment / Operations Work
85
+
86
+ Also read:
87
+
88
+ 1. `docs/06-operations/deployment-guide.md`
89
+ 2. `docs/06-operations/release.md`
90
+ 3. `docs/06-operations/security-policy.md`
91
+ 4. `docs/06-operations/troubleshooting.md`
92
+
93
+ ### OpenSpec Work
94
+
95
+ Also read:
96
+
97
+ 1. `docs/03-openspec/proposal-rule.md`
98
+ 2. `docs/03-openspec/design-rule.md`
99
+ 3. `docs/03-openspec/spec-rule.md`
100
+ 4. `docs/03-openspec/tasks-rule.md`
101
+
102
+ ## Hard Rules
103
+
104
+ - Durable registry data is YAML files under the plugin data directory.
105
+ - Registry data is never committed to Git.
106
+ - Credentials are references only; values never appear in registry files or tool output.
107
+ - Rule templates use interpolation only; no code execution.
108
+ - Production write operations and production-affecting management writes require approval.
109
+ - Conflicts, missing Skills and broken references fail loudly; nothing is chosen silently.
110
+ - Every completed change updates `docs/00-project/current-state.md`.
111
+
112
+ ## Directory Map
113
+
114
+ ```text
115
+ docs/
116
+ ├── 00-project/ # brief, current state, glossary, roadmap
117
+ ├── 01-architecture/ # design, data model, tools, storage, security, ADRs
118
+ ├── 02-harness/ # AI-assisted development harness standards
119
+ ├── 03-openspec/ # proposal/design/spec/tasks rules
120
+ ├── 04-development/ # coding, testing, local run, dependency rules
121
+ ├── 05-domain/ # environment/service/deployment/rule/binding templates
122
+ ├── 06-operations/ # deployment, release, security, troubleshooting
123
+ ├── 07-templates/ # reusable artifact templates
124
+ └── 99-archive/ # obsolete or historical docs
125
+ ```
126
+
127
+ ### Architecture Index
128
+
129
+ | Document | Purpose |
130
+ |---|---|
131
+ | `architecture-overview.md` | layers, components, request flows |
132
+ | `design.md` | V1 scope, algorithms, acceptance criteria |
133
+ | `detailed-design.md` | module contracts, algorithms, tool/HTTP specs, tests |
134
+ | `data-model.md` | record schemas and result types |
135
+ | `tool-contract.md` | model-facing tool inputs, outputs, errors |
136
+ | `storage-contract.md` | files, atomicity, sessions, migration |
137
+ | `module-boundaries.md` | module ownership and dependencies |
138
+ | `ui-design.md` | panels, transport, states, i18n, QA checklist |
139
+ | `security-model.md` | credential, policy and redaction controls |
140
+ | `api-verification.md` | verified DSH runtime facts and open probes |
141
+ | `implementation-plan.md` | ordered tasks, acceptance, cut line |
142
+ | `decisions/ADR-*.md` | accepted decisions (ADR-0009 = UI transport, ADR-0010 = environment/plane model, ADR-0011 = K8s node/access model) |
package/icon.svg ADDED
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <circle cx="32" cy="32" r="28" fill="#0ea5e9"/>
3
+ <path d="M22 20h20v8H22zm0 14h20v8H22z" fill="#ffffff"/>
4
+ </svg>
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * DSH Environment Manager - Host entry point.
3
+ *
4
+ * The implementation lives in `lib/` (compiled from `src/`); this shim keeps the
5
+ * bundle entry stable across builds.
6
+ */
7
+
8
+ export { name, inject, Config, apply } from './lib/index.js'
@@ -0,0 +1,67 @@
1
+ import type { Actor, CredentialDirectory, Diagnostic, FindResult, GetResult, ListResult, MetaResult, OperationResolution, RecordKind, RemoveOptions, RemoveResult, ResolveRequest, RouteRequest, SaveOptions, SaveResult, ServiceContext, SessionContext, SkillDirectory, ValidationReport } from '../domain/types.js';
2
+ import type { Logger } from '../logger.js';
3
+ export declare const VERSION = "0.1.0";
4
+ export interface AppOptions {
5
+ dataDir: string;
6
+ maxRecords: number;
7
+ writePolicy: {
8
+ allowUiProductionWrites: boolean;
9
+ };
10
+ skills: SkillDirectory | null;
11
+ credentials: CredentialDirectory | null;
12
+ logger: Logger;
13
+ defaults?: {
14
+ environmentId?: string;
15
+ };
16
+ }
17
+ export interface SaveContext {
18
+ actor?: Actor;
19
+ }
20
+ export interface GetContextOptions {
21
+ actor?: Actor;
22
+ }
23
+ export interface ResolveOutcome {
24
+ context: ServiceContext;
25
+ warnings: Diagnostic[];
26
+ }
27
+ export declare class App {
28
+ private readonly options;
29
+ private readonly loader;
30
+ private readonly sessions;
31
+ constructor(options: AppOptions);
32
+ get dataDir(): string;
33
+ init(): Promise<void>;
34
+ private snapshot;
35
+ private counts;
36
+ private warnings;
37
+ meta(): Promise<MetaResult>;
38
+ list(kind: RecordKind): Promise<ListResult>;
39
+ get(kind: RecordKind, id: string): Promise<GetResult>;
40
+ find(query: string): Promise<FindResult>;
41
+ saveYaml(kind: RecordKind, yaml: string, options?: SaveOptions & SaveContext): Promise<SaveResult>;
42
+ save(kind: RecordKind, raw: unknown, options?: SaveOptions & SaveContext): Promise<SaveResult>;
43
+ remove(kind: RecordKind, id: string, actor: Actor, options?: RemoveOptions): Promise<RemoveResult>;
44
+ validate(): Promise<ValidationReport>;
45
+ /**
46
+ * Store one SSH/web credential in the DSH credential service and return only
47
+ * its reference. Registry YAML must never contain the value itself.
48
+ */
49
+ setCredential(ref: string, value: string): Promise<{
50
+ ref: string;
51
+ configured: boolean;
52
+ }>;
53
+ /** Remove a credential owned by this plugin; other namespaces are rejected. */
54
+ unsetCredential(ref: string): Promise<{
55
+ ref: string;
56
+ removed: true;
57
+ }>;
58
+ resolve(request: ResolveRequest): Promise<ResolveOutcome>;
59
+ route(request: RouteRequest): Promise<OperationResolution>;
60
+ getContext(sessionId: string): Promise<SessionContext>;
61
+ setContext(sessionId: string, environmentId: string | null): Promise<SessionContext>;
62
+ needsProductionApproval(kind: RecordKind, raw: unknown): Promise<boolean>;
63
+ private mapFor;
64
+ private selectDeployment;
65
+ private isProductionRecord;
66
+ private describeCredentials;
67
+ }