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,31 +1,31 @@
1
- # Tasks Rule
2
-
3
- Tasks must be small and verifiable.
4
-
5
- ## Task Format
6
-
7
- ```markdown
8
- - [ ] Task name
9
- - Files:
10
- - Behavior:
11
- - Tests:
12
- - Verification:
13
- ```
14
-
15
- ## Rules
16
-
17
- - Do not combine unrelated modules in one task.
18
- - Do not add broad refactoring tasks.
19
- - Every implementation task must include tests or manual verification.
20
- - Docs must be updated when behavior or storage contract changes.
21
- - `docs/00-project/current-state.md` must be updated at the end.
22
-
23
- ## Good Task Example
24
-
25
- ```markdown
26
- - [ ] Implement environment registry storage
27
- - Files: src/storage/environment.js, tests/storage/environment.test.js
28
- - Behavior: read/write environment records atomically
29
- - Tests: create, read, update, missing file
30
- - Verification: npm test tests/storage/environment.test.js
31
- ```
1
+ # Tasks Rule
2
+
3
+ Tasks must be small and verifiable.
4
+
5
+ ## Task Format
6
+
7
+ ```markdown
8
+ - [ ] Task name
9
+ - Files:
10
+ - Behavior:
11
+ - Tests:
12
+ - Verification:
13
+ ```
14
+
15
+ ## Rules
16
+
17
+ - Do not combine unrelated modules in one task.
18
+ - Do not add broad refactoring tasks.
19
+ - Every implementation task must include tests or manual verification.
20
+ - Docs must be updated when behavior or storage contract changes.
21
+ - `docs/00-project/current-state.md` must be updated at the end.
22
+
23
+ ## Good Task Example
24
+
25
+ ```markdown
26
+ - [ ] Implement environment registry storage
27
+ - Files: src/storage/environment.js, tests/storage/environment.test.js
28
+ - Behavior: read/write environment records atomically
29
+ - Tests: create, read, update, missing file
30
+ - Verification: npm test tests/storage/environment.test.js
31
+ ```
@@ -1,67 +1,67 @@
1
- # Coding Style
2
-
3
- ## TypeScript (Host)
4
-
5
- - `strict: true`; do not disable it locally.
6
- - Prefer `interface` for records, `type` for unions and aliases.
7
- - No `any` at module boundaries. Use `unknown` and validate.
8
- - Validate all external input (YAML, tool arguments) with Zod.
9
- - Prefer `readonly` for data that must not be mutated.
10
- - Pure functions (`resolver`, `router`, `domain`) return discriminated unions for
11
- expected failures:
12
-
13
- ```ts
14
- type ResolveResult =
15
- | { ok: true; context: ServiceContext }
16
- | { ok: false; diagnostics: Diagnostic[] };
17
- ```
18
-
19
- - Tool and HTTP boundaries throw `EnvManagerError extends HarnessError`; they never
20
- return an `{ ok: false }` value. Catch unexpected errors and wrap them as
21
- `INTERNAL_ERROR` with a redacted message.
22
- - No floating promises. Await or return them.
23
-
24
- ## Purity
25
-
26
- - `resolver` and `router` are pure: no I/O, no clock, no randomness, no globals.
27
- - Inject dependencies (`SkillDirectory`, `CredentialDirectory`) as parameters.
28
- - Storage and registry may hold state; keep it inside instances, not module scope.
29
-
30
- ## Naming
31
-
32
- | Kind | Style | Example |
33
- |---|---|---|
34
- | files | kebab-case | `service-context.ts` |
35
- | types/interfaces | PascalCase | `DeploymentBinding` |
36
- | functions | camelCase | `resolveContext` |
37
- | constants | UPPER_SNAKE_CASE | `WRITE_OPERATIONS` |
38
- | record ids | kebab-case | `deploy-001` |
39
-
40
- ## Error handling
41
-
42
- - Every failure carries a `code` from the diagnostics catalogue.
43
- - Messages are user-facing and must not include secrets.
44
- - Never swallow an error silently. If it is expected, convert it to a diagnostic.
45
-
46
- ## JavaScript (Client)
47
-
48
- - ES modules; the artifact is the module-loader wrapper.
49
- - `React.createElement` (`h(...)`), no JSX.
50
- - No global side effects at module load beyond `load({...})`.
51
- - Register slots with `ctx.slots.inject` (it owns cleanup); wrap any other listener or
52
- disposable in `ctx.effect` and return its cleanup.
53
- - Route visible text through the client locale service.
54
-
55
- ## Formatting
56
-
57
- - 2 spaces
58
- - single quotes
59
- - no semicolons
60
- - trailing commas in multi-line literals
61
- - LF line endings
62
-
63
- ## Comments
64
-
65
- - JSDoc on exported functions and non-obvious invariants.
66
- - Explain why, not what.
67
- - Reference the design section when implementing a non-trivial rule, e.g. `// design §6.4`.
1
+ # Coding Style
2
+
3
+ ## TypeScript (Host)
4
+
5
+ - `strict: true`; do not disable it locally.
6
+ - Prefer `interface` for records, `type` for unions and aliases.
7
+ - No `any` at module boundaries. Use `unknown` and validate.
8
+ - Validate all external input (YAML, tool arguments) with Zod.
9
+ - Prefer `readonly` for data that must not be mutated.
10
+ - Pure functions (`resolver`, `router`, `domain`) return discriminated unions for
11
+ expected failures:
12
+
13
+ ```ts
14
+ type ResolveResult =
15
+ | { ok: true; context: ServiceContext }
16
+ | { ok: false; diagnostics: Diagnostic[] };
17
+ ```
18
+
19
+ - Tool and HTTP boundaries throw `EnvManagerError extends HarnessError`; they never
20
+ return an `{ ok: false }` value. Catch unexpected errors and wrap them as
21
+ `INTERNAL_ERROR` with a redacted message.
22
+ - No floating promises. Await or return them.
23
+
24
+ ## Purity
25
+
26
+ - `resolver` and `router` are pure: no I/O, no clock, no randomness, no globals.
27
+ - Inject dependencies (`SkillDirectory`, `CredentialDirectory`) as parameters.
28
+ - Storage and registry may hold state; keep it inside instances, not module scope.
29
+
30
+ ## Naming
31
+
32
+ | Kind | Style | Example |
33
+ |---|---|---|
34
+ | files | kebab-case | `service-context.ts` |
35
+ | types/interfaces | PascalCase | `DeploymentBinding` |
36
+ | functions | camelCase | `resolveContext` |
37
+ | constants | UPPER_SNAKE_CASE | `WRITE_OPERATIONS` |
38
+ | record ids | kebab-case | `deploy-001` |
39
+
40
+ ## Error handling
41
+
42
+ - Every failure carries a `code` from the diagnostics catalogue.
43
+ - Messages are user-facing and must not include secrets.
44
+ - Never swallow an error silently. If it is expected, convert it to a diagnostic.
45
+
46
+ ## JavaScript (Client)
47
+
48
+ - ES modules; the artifact is the module-loader wrapper.
49
+ - `React.createElement` (`h(...)`), no JSX.
50
+ - No global side effects at module load beyond `load({...})`.
51
+ - Register slots with `ctx.slots.inject` (it owns cleanup); wrap any other listener or
52
+ disposable in `ctx.effect` and return its cleanup.
53
+ - Route visible text through the client locale service.
54
+
55
+ ## Formatting
56
+
57
+ - 2 spaces
58
+ - single quotes
59
+ - no semicolons
60
+ - trailing commas in multi-line literals
61
+ - LF line endings
62
+
63
+ ## Comments
64
+
65
+ - JSDoc on exported functions and non-obvious invariants.
66
+ - Explain why, not what.
67
+ - Reference the design section when implementing a non-trivial rule, e.g. `// design §6.4`.
@@ -1,43 +1,43 @@
1
- # Dependency Policy
2
-
3
- ## Runtime dependencies
4
-
5
- Keep the set minimal and justified:
6
-
7
- | Package | Why |
8
- |---|---|
9
- | `zod` | schema validation for records and tool inputs |
10
- | `yaml` | YAML parse/serialize with typed results |
11
- | `@deepseek-ai/schemastery` | `Config` schema for the Host plugin |
12
-
13
- Anything else needs a proposal that explains why the standard library and the three
14
- packages above are insufficient.
15
-
16
- DSH-provided packages (`@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-llm`, `@deepseek-ai/cordis`) are
17
- peers, supplied by the profile; never bundle them.
18
-
19
- ## Development dependencies
20
-
21
- | Package | Why |
22
- |---|---|
23
- | `typescript` | Host build |
24
- | `vitest` | tests |
25
-
26
- Optional, with justification: `@types/node`, a linter, a formatter.
27
-
28
- ## Rules
29
-
30
- 1. No dependency that duplicates DSH-provided services (fs, credentials, approval, storage).
31
- 2. No database driver.
32
- 3. No client bundler unless a new ADR accepts it.
33
- 4. No native modules unless there is no alternative.
34
- 5. Check the license before adding.
35
- 6. Prefer a small maintained package over a large framework.
36
-
37
- ## Adding a dependency
38
-
39
- 1. Write an OpenSpec proposal or a task entry.
40
- 2. State the capability gap.
41
- 3. State alternatives considered.
42
- 4. Add it to `package.json` and the lockfile.
43
- 5. Mention it in `docs/01-architecture/design.md` §15.4 if it changes the build.
1
+ # Dependency Policy
2
+
3
+ ## Runtime dependencies
4
+
5
+ Keep the set minimal and justified:
6
+
7
+ | Package | Why |
8
+ |---|---|
9
+ | `zod` | schema validation for records and tool inputs |
10
+ | `yaml` | YAML parse/serialize with typed results |
11
+ | `@deepseek-ai/schemastery` | `Config` schema for the Host plugin |
12
+
13
+ Anything else needs a proposal that explains why the standard library and the three
14
+ packages above are insufficient.
15
+
16
+ DSH-provided packages (`@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-llm`, `@deepseek-ai/cordis`) are
17
+ peers, supplied by the profile; never bundle them.
18
+
19
+ ## Development dependencies
20
+
21
+ | Package | Why |
22
+ |---|---|
23
+ | `typescript` | Host build |
24
+ | `vitest` | tests |
25
+
26
+ Optional, with justification: `@types/node`, a linter, a formatter.
27
+
28
+ ## Rules
29
+
30
+ 1. No dependency that duplicates DSH-provided services (fs, credentials, approval, storage).
31
+ 2. No database driver.
32
+ 3. No client bundler unless a new ADR accepts it.
33
+ 4. No native modules unless there is no alternative.
34
+ 5. Check the license before adding.
35
+ 6. Prefer a small maintained package over a large framework.
36
+
37
+ ## Adding a dependency
38
+
39
+ 1. Write an OpenSpec proposal or a task entry.
40
+ 2. State the capability gap.
41
+ 3. State alternatives considered.
42
+ 4. Add it to `package.json` and the lockfile.
43
+ 5. Mention it in `docs/01-architecture/design.md` §15.4 if it changes the build.
@@ -1,85 +1,85 @@
1
- # Development Guide
2
-
3
- > Status: this guide describes the V1 target. The repository currently ships the JavaScript skeleton; `src/`, `lib/`, `tsconfig.json` and the npm scripts are added during V1 implementation. See `docs/00-project/current-state.md`.
4
-
5
- ## Prerequisites
6
-
7
- - Node.js matching the DSH runtime
8
- - npm
9
-
10
- ## First Run
11
-
12
- ```bash
13
- npm install
14
- npm run build
15
- npm test
16
- ```
17
-
18
- ## Project Layout
19
-
20
- ```text
21
- dsh-env-manager/
22
- ├── index.js # Host entry shim over lib/index.js
23
- ├── client.js # Client module (plain JS)
24
- ├── cordis.patch.yml # Cordis patch
25
- ├── package.json # Bundle manifest
26
- ├── tsconfig.json # Host build config
27
- ├── src/ # TypeScript host sources
28
- ├── lib/ # Build output (git-ignored)
29
- ├── locale/ # Display metadata
30
- ├── docs/ # Project documentation
31
- ├── data/ # Runtime registry data (git-ignored)
32
- └── tests/ # Vitest tests
33
- ```
34
-
35
- ## Build
36
-
37
- ```bash
38
- npm run build # tsc -p tsconfig.json
39
- npm run build:watch # optional watch mode
40
- ```
41
-
42
- The Host entry `index.js` re-exports `lib/index.js`. Do not edit `lib/` by hand.
43
-
44
- ## Test
45
-
46
- ```bash
47
- npm test # vitest run
48
- npm run test:watch # vitest
49
- ```
50
-
51
- ## Install in a DSH Profile
52
-
53
- In a DSH session, call the `plugin_manager` tool with `action: install_bundle` and the absolute repository path as `target`. Restart DSH if the bundle was already installed.
54
-
55
- Do not use `dsh plugin add` for bundle selection; that forwards to pnpm only.
56
-
57
- ## Development Loop
58
-
59
- 1. Read the relevant docs (`docs/README.md` decides which).
60
- 2. Change `src/` or `client.js`.
61
- 3. Build and test.
62
- 4. Reinstall the bundle to see Host/Client changes.
63
- 5. Update `docs/00-project/current-state.md`.
64
-
65
- ## Client Changes
66
-
67
- `client.js` is plain JavaScript and needs no build. The Host serves it as the bundle's `./client` export.
68
-
69
- Keep the module-loader wrapper intact:
70
-
71
- ```js
72
- window.__ModuleLoader__.load({ id: 'dsh-env-manager', factory(require) { ... } })
73
- ```
74
-
75
- ## Data Directory
76
-
77
- Do not commit `data/`. It is created on first run at the resolved `dataDir`; the startup log reports the path.
78
-
79
- ## Updating Docs
80
-
81
- After every meaningful change update:
82
-
83
- - `docs/00-project/current-state.md`
84
- - the matching architecture document when behavior or schemas changed
85
- - OpenSpec artifacts when used
1
+ # Development Guide
2
+
3
+ > Status: this guide describes the V1 target. The repository currently ships the JavaScript skeleton; `src/`, `lib/`, `tsconfig.json` and the npm scripts are added during V1 implementation. See `docs/00-project/current-state.md`.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js matching the DSH runtime
8
+ - npm
9
+
10
+ ## First Run
11
+
12
+ ```bash
13
+ npm install
14
+ npm run build
15
+ npm test
16
+ ```
17
+
18
+ ## Project Layout
19
+
20
+ ```text
21
+ dsh-env-manager/
22
+ ├── index.js # Host entry shim over lib/index.js
23
+ ├── client.js # Client module (plain JS)
24
+ ├── cordis.patch.yml # Cordis patch
25
+ ├── package.json # Bundle manifest
26
+ ├── tsconfig.json # Host build config
27
+ ├── src/ # TypeScript host sources
28
+ ├── lib/ # Build output (git-ignored)
29
+ ├── locale/ # Display metadata
30
+ ├── docs/ # Project documentation
31
+ ├── data/ # Runtime registry data (git-ignored)
32
+ └── tests/ # Vitest tests
33
+ ```
34
+
35
+ ## Build
36
+
37
+ ```bash
38
+ npm run build # tsc -p tsconfig.json
39
+ npm run build:watch # optional watch mode
40
+ ```
41
+
42
+ The Host entry `index.js` re-exports `lib/index.js`. Do not edit `lib/` by hand.
43
+
44
+ ## Test
45
+
46
+ ```bash
47
+ npm test # vitest run
48
+ npm run test:watch # vitest
49
+ ```
50
+
51
+ ## Install in a DSH Profile
52
+
53
+ In a DSH session, call the `plugin_manager` tool with `action: install_bundle` and the absolute repository path as `target`. Restart DSH if the bundle was already installed.
54
+
55
+ Do not use `dsh plugin add` for bundle selection; that forwards to pnpm only.
56
+
57
+ ## Development Loop
58
+
59
+ 1. Read the relevant docs (`docs/README.md` decides which).
60
+ 2. Change `src/` or `client.js`.
61
+ 3. Build and test.
62
+ 4. Reinstall the bundle to see Host/Client changes.
63
+ 5. Update `docs/00-project/current-state.md`.
64
+
65
+ ## Client Changes
66
+
67
+ `client.js` is plain JavaScript and needs no build. The Host serves it as the bundle's `./client` export.
68
+
69
+ Keep the module-loader wrapper intact:
70
+
71
+ ```js
72
+ window.__ModuleLoader__.load({ id: 'dsh-env-manager', factory(require) { ... } })
73
+ ```
74
+
75
+ ## Data Directory
76
+
77
+ Do not commit `data/`. It is created on first run at the resolved `dataDir`; the startup log reports the path.
78
+
79
+ ## Updating Docs
80
+
81
+ After every meaningful change update:
82
+
83
+ - `docs/00-project/current-state.md`
84
+ - the matching architecture document when behavior or schemas changed
85
+ - OpenSpec artifacts when used
@@ -1,105 +1,105 @@
1
- # Directory Convention
2
-
3
- > Status: target layout for V1. Directories marked as V1 are created during implementation; see `docs/00-project/current-state.md`.
4
-
5
- ## Root
6
-
7
- | Path | Purpose |
8
- |---|---|
9
- | `index.js` | Host entry shim; re-exports `lib/index.js` |
10
- | `client.js` | Client module (plain JS, module-loader format) |
11
- | `cordis.patch.yml` | Cordis bundle patch |
12
- | `package.json` | Bundle manifest, scripts, dependencies |
13
- | `tsconfig.json` | Host build configuration |
14
- | `lib/` | Build output; git-ignored |
15
- | `src/` | TypeScript Host sources |
16
- | `tests/` | Vitest tests and fixtures |
17
- | `data/` | Runtime registry data; git-ignored |
18
- | `locale/` | `en.json`, `zh.json` |
19
- | `docs/` | Project documentation |
20
- | `icon.svg` | Plugin icon |
21
-
22
- ## `src/`
23
-
24
- ```text
25
- src/
26
- ├── index.ts # apply(): wiring, tools, HTTP route
27
- ├── config.ts # schemastery Config
28
- ├── logger.ts # ctx logger wrapper
29
- ├── domain/
30
- │ ├── types.ts # interfaces and enums
31
- │ ├── schemas.ts # Zod schemas, parseRecord
32
- │ ├── constants.ts # operation ids, limits, patterns
33
- │ └── errors.ts # EnvManagerError, codes
34
- ├── storage/
35
- │ ├── paths.ts # dataDir resolution, id/path guards
36
- │ ├── atomic.ts # temp+fsync+rename write, backups
37
- │ ├── records.ts # read/write/delete one record
38
- │ ├── sessions.ts # session state files
39
- │ └── layout.ts # directory creation, tmp cleanup
40
- ├── registry/
41
- │ ├── registry.ts # load, snapshot, lookup, reload
42
- │ ├── aliases.ts # alias index
43
- │ └── integrity.ts # referential integrity diagnostics
44
- ├── resolver/
45
- │ ├── template.ts # ${...} parsing and substitution
46
- │ ├── graph.ts # reference graph, cycles
47
- │ ├── layers.ts # build ordered layers
48
- │ ├── merge.ts # field-level merge
49
- │ ├── context.ts # ServiceContext assembly
50
- │ └── provenance.ts # provenance construction
51
- ├── router/
52
- │ ├── match.ts # match level classification
53
- │ ├── router.ts # selection, conflicts
54
- │ ├── skills.ts # SkillDirectory adapter
55
- │ ├── policy.ts # approval and production rules
56
- │ └── parameters.ts # parameter mapping
57
- ├── session/
58
- │ └── session-context.ts
59
- ├── app/
60
- │ ├── app.ts # use cases shared by tools and HTTP
61
- │ └── actor.ts # 'agent' | 'ui' policy
62
- ├── tools/
63
- │ ├── define.ts # shared schemas and render helpers
64
- │ ├── approval.ts # ctx.approval wrapper
65
- │ ├── read.ts # env_list/get/find/get_context
66
- │ ├── resolve.ts # env_resolve/resolve_operation
67
- │ ├── write.ts # env_save/delete/set_context
68
- │ └── validate.ts # env_validate
69
- ├── transport/
70
- │ ├── route.ts # webServer registration, body handling
71
- │ ├── auth.ts # header, origin, size checks
72
- │ ├── ops.ts # op table → app calls
73
- │ └── envelope.ts # { ok, data } / { ok:false, error }
74
- └── memory-bridge/
75
- ├── contract.ts
76
- └── null-adapter.ts
77
- ```
78
-
79
- `logger.ts` sits at the root because every module may log; it must not import them.
80
-
81
- ## `tests/`
82
-
83
- ```text
84
- tests/
85
- ├── domain/
86
- ├── storage/
87
- ├── registry/
88
- ├── resolver/
89
- ├── router/
90
- ├── session/
91
- ├── app/
92
- ├── tools/
93
- ├── http/
94
- └── fixtures/
95
- ```
96
-
97
- - One test file per module: `<module>.test.ts`.
98
- - Fixtures are small YAML files with obviously fake values.
99
- - Never commit real hostnames, IPs, URLs or credentials.
100
-
101
- ## Adding a module
102
-
103
- 1. It must fit an existing boundary in `module-boundaries.md`.
104
- 2. A new boundary needs an ADR.
105
- 3. Update the tree in this document and in `AGENTS.md`.
1
+ # Directory Convention
2
+
3
+ > Status: target layout for V1. Directories marked as V1 are created during implementation; see `docs/00-project/current-state.md`.
4
+
5
+ ## Root
6
+
7
+ | Path | Purpose |
8
+ |---|---|
9
+ | `index.js` | Host entry shim; re-exports `lib/index.js` |
10
+ | `client.js` | Client module (plain JS, module-loader format) |
11
+ | `cordis.patch.yml` | Cordis bundle patch |
12
+ | `package.json` | Bundle manifest, scripts, dependencies |
13
+ | `tsconfig.json` | Host build configuration |
14
+ | `lib/` | Build output; git-ignored |
15
+ | `src/` | TypeScript Host sources |
16
+ | `tests/` | Vitest tests and fixtures |
17
+ | `data/` | Runtime registry data; git-ignored |
18
+ | `locale/` | `en.json`, `zh.json` |
19
+ | `docs/` | Project documentation |
20
+ | `icon.svg` | Plugin icon |
21
+
22
+ ## `src/`
23
+
24
+ ```text
25
+ src/
26
+ ├── index.ts # apply(): wiring, tools, HTTP route
27
+ ├── config.ts # schemastery Config
28
+ ├── logger.ts # ctx logger wrapper
29
+ ├── domain/
30
+ │ ├── types.ts # interfaces and enums
31
+ │ ├── schemas.ts # Zod schemas, parseRecord
32
+ │ ├── constants.ts # operation ids, limits, patterns
33
+ │ └── errors.ts # EnvManagerError, codes
34
+ ├── storage/
35
+ │ ├── paths.ts # dataDir resolution, id/path guards
36
+ │ ├── atomic.ts # temp+fsync+rename write, backups
37
+ │ ├── records.ts # read/write/delete one record
38
+ │ ├── sessions.ts # session state files
39
+ │ └── layout.ts # directory creation, tmp cleanup
40
+ ├── registry/
41
+ │ ├── registry.ts # load, snapshot, lookup, reload
42
+ │ ├── aliases.ts # alias index
43
+ │ └── integrity.ts # referential integrity diagnostics
44
+ ├── resolver/
45
+ │ ├── template.ts # ${...} parsing and substitution
46
+ │ ├── graph.ts # reference graph, cycles
47
+ │ ├── layers.ts # build ordered layers
48
+ │ ├── merge.ts # field-level merge
49
+ │ ├── context.ts # ServiceContext assembly
50
+ │ └── provenance.ts # provenance construction
51
+ ├── router/
52
+ │ ├── match.ts # match level classification
53
+ │ ├── router.ts # selection, conflicts
54
+ │ ├── skills.ts # SkillDirectory adapter
55
+ │ ├── policy.ts # approval and production rules
56
+ │ └── parameters.ts # parameter mapping
57
+ ├── session/
58
+ │ └── session-context.ts
59
+ ├── app/
60
+ │ ├── app.ts # use cases shared by tools and HTTP
61
+ │ └── actor.ts # 'agent' | 'ui' policy
62
+ ├── tools/
63
+ │ ├── define.ts # shared schemas and render helpers
64
+ │ ├── approval.ts # ctx.approval wrapper
65
+ │ ├── read.ts # env_list/get/find/get_context
66
+ │ ├── resolve.ts # env_resolve/resolve_operation
67
+ │ ├── write.ts # env_save/delete/set_context
68
+ │ └── validate.ts # env_validate
69
+ ├── transport/
70
+ │ ├── route.ts # webServer registration, body handling
71
+ │ ├── auth.ts # header, origin, size checks
72
+ │ ├── ops.ts # op table → app calls
73
+ │ └── envelope.ts # { ok, data } / { ok:false, error }
74
+ └── memory-bridge/
75
+ ├── contract.ts
76
+ └── null-adapter.ts
77
+ ```
78
+
79
+ `logger.ts` sits at the root because every module may log; it must not import them.
80
+
81
+ ## `tests/`
82
+
83
+ ```text
84
+ tests/
85
+ ├── domain/
86
+ ├── storage/
87
+ ├── registry/
88
+ ├── resolver/
89
+ ├── router/
90
+ ├── session/
91
+ ├── app/
92
+ ├── tools/
93
+ ├── http/
94
+ └── fixtures/
95
+ ```
96
+
97
+ - One test file per module: `<module>.test.ts`.
98
+ - Fixtures are small YAML files with obviously fake values.
99
+ - Never commit real hostnames, IPs, URLs or credentials.
100
+
101
+ ## Adding a module
102
+
103
+ 1. It must fit an existing boundary in `module-boundaries.md`.
104
+ 2. A new boundary needs an ADR.
105
+ 3. Update the tree in this document and in `AGENTS.md`.