container-superposition 0.1.6 → 0.1.8

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 (238) hide show
  1. package/README.md +24 -15
  2. package/dist/scripts/init.js +1 -1534
  3. package/dist/scripts/init.js.map +1 -1
  4. package/dist/tool/cli/args.d.ts +20 -0
  5. package/dist/tool/cli/args.d.ts.map +1 -0
  6. package/dist/tool/cli/args.js +325 -0
  7. package/dist/tool/cli/args.js.map +1 -0
  8. package/dist/tool/cli/run.d.ts +2 -0
  9. package/dist/tool/cli/run.d.ts.map +1 -0
  10. package/dist/tool/cli/run.js +318 -0
  11. package/dist/tool/cli/run.js.map +1 -0
  12. package/dist/tool/commands/adopt.d.ts.map +1 -1
  13. package/dist/tool/commands/adopt.js +1 -27
  14. package/dist/tool/commands/adopt.js.map +1 -1
  15. package/dist/tool/commands/doctor.d.ts +3 -0
  16. package/dist/tool/commands/doctor.d.ts.map +1 -1
  17. package/dist/tool/commands/doctor.js +1068 -70
  18. package/dist/tool/commands/doctor.js.map +1 -1
  19. package/dist/tool/commands/explain.d.ts.map +1 -1
  20. package/dist/tool/commands/explain.js +18 -0
  21. package/dist/tool/commands/explain.js.map +1 -1
  22. package/dist/tool/commands/migrate.d.ts +7 -0
  23. package/dist/tool/commands/migrate.d.ts.map +1 -0
  24. package/dist/tool/commands/migrate.js +52 -0
  25. package/dist/tool/commands/migrate.js.map +1 -0
  26. package/dist/tool/questionnaire/answers.d.ts +16 -0
  27. package/dist/tool/questionnaire/answers.d.ts.map +1 -0
  28. package/dist/tool/questionnaire/answers.js +102 -0
  29. package/dist/tool/questionnaire/answers.js.map +1 -0
  30. package/dist/tool/questionnaire/composer.d.ts +3 -3
  31. package/dist/tool/questionnaire/composer.d.ts.map +1 -1
  32. package/dist/tool/questionnaire/composer.js +902 -37
  33. package/dist/tool/questionnaire/composer.js.map +1 -1
  34. package/dist/tool/questionnaire/presets.d.ts +60 -0
  35. package/dist/tool/questionnaire/presets.d.ts.map +1 -0
  36. package/dist/tool/questionnaire/presets.js +164 -0
  37. package/dist/tool/questionnaire/presets.js.map +1 -0
  38. package/dist/tool/questionnaire/questionnaire.d.ts +10 -0
  39. package/dist/tool/questionnaire/questionnaire.d.ts.map +1 -0
  40. package/dist/tool/questionnaire/questionnaire.js +580 -0
  41. package/dist/tool/questionnaire/questionnaire.js.map +1 -0
  42. package/dist/tool/schema/manifest-migrations.d.ts +5 -0
  43. package/dist/tool/schema/manifest-migrations.d.ts.map +1 -1
  44. package/dist/tool/schema/manifest-migrations.js +45 -0
  45. package/dist/tool/schema/manifest-migrations.js.map +1 -1
  46. package/dist/tool/schema/overlay-loader.d.ts.map +1 -1
  47. package/dist/tool/schema/overlay-loader.js +25 -0
  48. package/dist/tool/schema/overlay-loader.js.map +1 -1
  49. package/dist/tool/schema/project-config.d.ts +14 -2
  50. package/dist/tool/schema/project-config.d.ts.map +1 -1
  51. package/dist/tool/schema/project-config.js +277 -34
  52. package/dist/tool/schema/project-config.js.map +1 -1
  53. package/dist/tool/schema/target-rules.d.ts +78 -0
  54. package/dist/tool/schema/target-rules.d.ts.map +1 -0
  55. package/dist/tool/schema/target-rules.js +367 -0
  56. package/dist/tool/schema/target-rules.js.map +1 -0
  57. package/dist/tool/schema/types.d.ts +123 -12
  58. package/dist/tool/schema/types.d.ts.map +1 -1
  59. package/dist/tool/utils/merge.d.ts.map +1 -1
  60. package/dist/tool/utils/merge.js +9 -0
  61. package/dist/tool/utils/merge.js.map +1 -1
  62. package/dist/tool/utils/parameters.d.ts +76 -0
  63. package/dist/tool/utils/parameters.d.ts.map +1 -0
  64. package/dist/tool/utils/parameters.js +125 -0
  65. package/dist/tool/utils/parameters.js.map +1 -0
  66. package/dist/tool/utils/paths.d.ts +2 -0
  67. package/dist/tool/utils/paths.d.ts.map +1 -0
  68. package/dist/tool/utils/paths.js +31 -0
  69. package/dist/tool/utils/paths.js.map +1 -0
  70. package/docs/creating-overlays.md +151 -2
  71. package/docs/deployment-targets.md +88 -56
  72. package/docs/examples.md +20 -17
  73. package/docs/filesystem-contract.md +5 -0
  74. package/docs/minimal-and-editor.md +65 -5
  75. package/docs/overlay-imports.md +202 -101
  76. package/docs/overlays.md +162 -34
  77. package/docs/quick-reference.md +99 -0
  78. package/docs/specs/003-mkdocs2-overlay/spec.md +114 -0
  79. package/docs/specs/004-doctor-fix/spec.md +70 -0
  80. package/docs/specs/005-cuda-overlay/spec.md +101 -0
  81. package/docs/specs/006-rocm-overlay/spec.md +109 -0
  82. package/docs/specs/007-init-project-file/spec.md +66 -0
  83. package/docs/specs/007-target-aware-generation/spec.md +126 -0
  84. package/docs/specs/008-project-file-canonical/spec.md +83 -0
  85. package/docs/specs/009-project-env/spec.md +147 -0
  86. package/docs/specs/010-compose-env-materialization/spec.md +130 -0
  87. package/docs/specs/011-overlay-parameters/spec.md +235 -0
  88. package/overlays/.shared/README.md +105 -21
  89. package/overlays/.shared/compose/common-healthchecks.md +60 -0
  90. package/overlays/.shared/compose/nvidia-gpu-devcontainer.yml +22 -0
  91. package/overlays/.shared/vscode/recommended-extensions.json +15 -11
  92. package/overlays/alertmanager/setup.sh +4 -19
  93. package/overlays/alertmanager/verify.sh +8 -9
  94. package/overlays/all/README.md +43 -0
  95. package/overlays/all/devcontainer.patch.json +6 -0
  96. package/overlays/all/overlay.yml +14 -0
  97. package/overlays/amp/setup.sh +5 -0
  98. package/overlays/bun/setup.sh +10 -1
  99. package/overlays/bun/verify.sh +6 -1
  100. package/overlays/claude-code/setup.sh +5 -0
  101. package/overlays/cloudflared/setup.sh +9 -12
  102. package/overlays/codex/README.md +9 -6
  103. package/overlays/codex/devcontainer.patch.json +7 -1
  104. package/overlays/codex/setup.sh +5 -0
  105. package/overlays/codex/verify.sh +8 -0
  106. package/overlays/comfyui/.env.example +34 -0
  107. package/overlays/comfyui/README.md +342 -0
  108. package/overlays/comfyui/devcontainer.patch.json +15 -0
  109. package/overlays/comfyui/docker-compose.yml +39 -0
  110. package/overlays/comfyui/overlay.yml +20 -0
  111. package/overlays/comfyui/setup.sh +36 -0
  112. package/overlays/comfyui/verify.sh +103 -0
  113. package/overlays/commitlint/setup.sh +5 -0
  114. package/overlays/cuda/README.md +179 -0
  115. package/overlays/cuda/devcontainer.patch.json +7 -0
  116. package/overlays/cuda/overlay.yml +17 -0
  117. package/overlays/cuda/setup.sh +32 -0
  118. package/overlays/cuda/verify.sh +38 -0
  119. package/overlays/devcontainer-cli/README.md +50 -0
  120. package/overlays/devcontainer-cli/devcontainer.patch.json +13 -0
  121. package/overlays/devcontainer-cli/overlay.yml +16 -0
  122. package/overlays/devcontainer-cli/setup.sh +14 -0
  123. package/overlays/direnv/devcontainer.patch.json +6 -0
  124. package/overlays/direnv/setup.sh +7 -6
  125. package/overlays/dotnet/setup.sh +14 -7
  126. package/overlays/duckdb/devcontainer.patch.json +1 -2
  127. package/overlays/gcloud/devcontainer.patch.json +0 -6
  128. package/overlays/gcloud/setup.sh +51 -0
  129. package/overlays/gemini-cli/setup.sh +5 -0
  130. package/overlays/git-helpers/devcontainer.patch.json +2 -1
  131. package/overlays/go/setup.sh +15 -14
  132. package/overlays/jaeger/overlay.yml +2 -0
  133. package/overlays/just/setup.sh +5 -17
  134. package/overlays/k3d/README.md +201 -0
  135. package/overlays/k3d/devcontainer.patch.json +9 -0
  136. package/overlays/k3d/overlay.yml +19 -0
  137. package/overlays/k3d/setup.sh +34 -0
  138. package/overlays/k3d/verify.sh +38 -0
  139. package/overlays/keycloak/docker-compose.yml +6 -4
  140. package/overlays/keycloak/verify.sh +4 -3
  141. package/overlays/kind/devcontainer.patch.json +1 -2
  142. package/overlays/kind/setup.sh +8 -17
  143. package/overlays/minio/setup.sh +10 -18
  144. package/overlays/mkdocs/overlay.yml +2 -1
  145. package/overlays/mkdocs2/README.md +135 -0
  146. package/overlays/mkdocs2/devcontainer.patch.json +19 -0
  147. package/overlays/mkdocs2/overlay.yml +17 -0
  148. package/overlays/mkdocs2/setup.sh +67 -0
  149. package/overlays/mkdocs2/verify.sh +35 -0
  150. package/overlays/modern-cli-tools/devcontainer.patch.json +7 -1
  151. package/overlays/modern-cli-tools/setup.sh +21 -71
  152. package/overlays/mongodb/devcontainer.patch.json +0 -6
  153. package/overlays/mongodb/setup.sh +59 -0
  154. package/overlays/mysql/verify.sh +4 -3
  155. package/overlays/nats/.env.example +1 -1
  156. package/overlays/nats/README.md +1 -1
  157. package/overlays/nats/docker-compose.yml +1 -1
  158. package/overlays/ngrok/setup.sh +9 -6
  159. package/overlays/nodejs/setup.sh +5 -0
  160. package/overlays/ollama/.env.example +14 -0
  161. package/overlays/ollama/README.md +325 -0
  162. package/overlays/ollama/devcontainer.patch.json +14 -0
  163. package/overlays/ollama/docker-compose.yml +24 -0
  164. package/overlays/ollama/overlay.yml +22 -0
  165. package/overlays/ollama/setup.sh +106 -0
  166. package/overlays/ollama/verify.sh +99 -0
  167. package/overlays/open-webui/.env.example +5 -0
  168. package/overlays/open-webui/README.md +162 -0
  169. package/overlays/open-webui/devcontainer.patch.json +14 -0
  170. package/overlays/open-webui/docker-compose.yml +23 -0
  171. package/overlays/open-webui/overlay.yml +38 -0
  172. package/overlays/openapi-tools/devcontainer.patch.json +1 -2
  173. package/overlays/openapi-tools/setup.sh +9 -8
  174. package/overlays/opencode/setup.sh +5 -0
  175. package/overlays/otel-collector/overlay.yml +2 -0
  176. package/overlays/otel-collector/setup.sh +3 -16
  177. package/overlays/otel-demo-nodejs/verify.sh +8 -9
  178. package/overlays/otel-demo-python/verify.sh +16 -10
  179. package/overlays/pandoc/README.md +22 -15
  180. package/overlays/pandoc/devcontainer.patch.json +6 -2
  181. package/overlays/pandoc/setup.sh +217 -18
  182. package/overlays/pandoc/verify.sh +16 -4
  183. package/overlays/pgvector/.env.example +6 -0
  184. package/overlays/pgvector/README.md +215 -0
  185. package/overlays/pgvector/devcontainer.patch.json +23 -0
  186. package/overlays/pgvector/docker-compose.yml +32 -0
  187. package/overlays/pgvector/overlay.yml +44 -0
  188. package/overlays/playwright/devcontainer.patch.json +3 -1
  189. package/overlays/playwright/setup.sh +37 -0
  190. package/overlays/postgres/.env.example +5 -5
  191. package/overlays/postgres/devcontainer.patch.json +4 -4
  192. package/overlays/postgres/docker-compose.yml +15 -5
  193. package/overlays/postgres/overlay.yml +19 -1
  194. package/overlays/powershell/setup.sh +49 -13
  195. package/overlays/pre-commit/setup.sh +12 -3
  196. package/overlays/prometheus/overlay.yml +2 -0
  197. package/overlays/promtail/verify.sh +16 -10
  198. package/overlays/pulumi/devcontainer.patch.json +1 -1
  199. package/overlays/python/setup.sh +28 -9
  200. package/overlays/python/verify.sh +4 -2
  201. package/overlays/qdrant/.env.example +4 -0
  202. package/overlays/qdrant/README.md +216 -0
  203. package/overlays/qdrant/devcontainer.patch.json +20 -0
  204. package/overlays/qdrant/docker-compose.yml +25 -0
  205. package/overlays/qdrant/overlay.yml +40 -0
  206. package/overlays/redpanda/docker-compose.yml +3 -5
  207. package/overlays/rocm/README.md +227 -0
  208. package/overlays/rocm/devcontainer.patch.json +4 -0
  209. package/overlays/rocm/overlay.yml +17 -0
  210. package/overlays/rocm/setup.sh +45 -0
  211. package/overlays/rocm/verify.sh +47 -0
  212. package/overlays/rust/setup.sh +11 -18
  213. package/overlays/skaffold/README.md +256 -0
  214. package/overlays/skaffold/devcontainer.patch.json +9 -0
  215. package/overlays/skaffold/overlay.yml +20 -0
  216. package/overlays/skaffold/setup.sh +33 -0
  217. package/overlays/skaffold/verify.sh +24 -0
  218. package/overlays/spec-kit/setup.sh +7 -3
  219. package/overlays/sqlite/setup.sh +14 -14
  220. package/overlays/sqlserver/docker-compose.yml +3 -3
  221. package/overlays/sqlserver/verify.sh +22 -5
  222. package/overlays/tempo/verify.sh +16 -10
  223. package/overlays/tilt/devcontainer.patch.json +1 -2
  224. package/overlays/tilt/setup.sh +14 -4
  225. package/overlays/windsurf-cli/setup.sh +27 -4
  226. package/overlays/windsurf-cli/verify.sh +13 -3
  227. package/package.json +4 -2
  228. package/templates/scripts/setup-utils.sh +228 -0
  229. package/tool/schema/config.schema.json +141 -9
  230. package/tool/schema/overlay-manifest.schema.json +38 -0
  231. package/overlays/.shared/compose/common-healthchecks.yml +0 -38
  232. /package/overlays/otel-demo-nodejs/{Dockerfile-otel-demo-nodejs → Dockerfile} +0 -0
  233. /package/overlays/otel-demo-nodejs/{package-otel-demo-nodejs.json → package.json} +0 -0
  234. /package/overlays/otel-demo-nodejs/{server-otel-demo-nodejs.js → server.js} +0 -0
  235. /package/overlays/otel-demo-nodejs/{tracing-otel-demo-nodejs.js → tracing.js} +0 -0
  236. /package/overlays/otel-demo-python/{Dockerfile-otel-demo-python → Dockerfile} +0 -0
  237. /package/overlays/otel-demo-python/{app-otel-demo-python.py → app.py} +0 -0
  238. /package/overlays/otel-demo-python/{requirements-otel-demo-python.txt → requirements.txt} +0 -0
@@ -0,0 +1,130 @@
1
+ # Feature Specification: Compose Env Materialization and Env Template Naming
2
+
3
+ **Feature Branch**: `codex/compose-env-materialization`
4
+ **Created**: 2026-03-29
5
+ **Status**: Implementing
6
+ **Input**: User request
7
+
8
+ ## Review & Approval _(mandatory before implementation)_
9
+
10
+ - **Spec Path**: `docs/specs/010-compose-env-materialization/spec.md`
11
+ - **Commit Status**: Committed
12
+ - **Review Status**: Pending
13
+ - **Implementation Gate**: No implementation code may begin until this spec is committed and reviewed.
14
+
15
+ ## User Scenarios & Testing _(mandatory)_
16
+
17
+ ### User Story 1 — Compose env values materialize into .devcontainer/.env (Priority: P1)
18
+
19
+ A developer sets concrete env values in `superposition.yml` on a `compose` stack and expects
20
+ them to be written to `.devcontainer/.env` (not embedded in `docker-compose.yml`) so that
21
+ secrets are not committed to source control inside generated YAML.
22
+
23
+ **Why this priority**: Embedding resolved values directly in `docker-compose.yml` would expose
24
+ secrets or host-specific values in generated files that are typically committed to source control.
25
+ Materializing them into `.devcontainer/.env` keeps generated config template-only.
26
+
27
+ **Independent Test**: Set `env: {SECRET_KEY: supersecret}` on a compose-stack project, run
28
+ `regen`, and confirm: (a) `docker-compose.yml` contains
29
+ `services.devcontainer.environment.SECRET_KEY: ${SECRET_KEY}`, (b) `.devcontainer/.env` contains
30
+ `SECRET_KEY=supersecret`, and (c) the literal value `supersecret` does not appear in
31
+ `docker-compose.yml`.
32
+
33
+ **Acceptance Scenarios**:
34
+
35
+ 1. **Given** `env: {API_KEY: abc123}` on a compose stack, **When** generation runs, **Then** `docker-compose.yml` has `API_KEY: ${API_KEY}` and `.devcontainer/.env` has `API_KEY=abc123`.
36
+ 2. **Given** `env: {NAME: ${NAME:-default}}`, **When** generation runs with a root `.env` that sets `NAME=prod`, **Then** `.devcontainer/.env` receives `NAME=prod`.
37
+ 3. **Given** `env: {NAME: ${NAME}}` and no root `.env` entry for `NAME`, **When** generation runs, **Then** `.devcontainer/.env` does not include `NAME=` and Docker Compose shell fallback still works.
38
+
39
+ ---
40
+
41
+ ### User Story 2 — Configure env template entries with clearly named project-file field (Priority: P1)
42
+
43
+ A developer updates their `superposition.yml` to use `customizations.envTemplate` (instead of
44
+ the previously named `customizations.environment`) and expects the generated `.env.example`
45
+ content to be identical to what the old field produced.
46
+
47
+ **Why this priority**: The existing `environment` key is misleading — it writes to `.env.example`
48
+ (a template), not to the runtime container environment. Renaming it clarifies intent and prevents
49
+ confusion with the new `env:` field.
50
+
51
+ **Independent Test**: Replace `customizations.environment` with `customizations.envTemplate` in a
52
+ project file, run `regen`, and confirm the generated `.env.example` is byte-for-byte identical to
53
+ the output produced with the old key.
54
+
55
+ **Acceptance Scenarios**:
56
+
57
+ 1. **Given** `customizations.envTemplate: {FOO: bar}`, **When** generation runs, **Then** `.devcontainer/.env.example` contains `FOO=bar`.
58
+ 2. **Given** `customizations.environment: {FOO: bar}` (deprecated alias), **When** generation runs, **Then** `.devcontainer/.env.example` still contains `FOO=bar` (backward-compatible).
59
+ 3. **Given** a project file using `environment`, **When** it is read by the project loader, **Then** a deprecation warning is emitted directing users to rename the key.
60
+
61
+ ---
62
+
63
+ ### User Story 3 — remoteEnv wiring for compose env entries (Priority: P2)
64
+
65
+ A developer on a compose stack expects that compose-targeted env variables are also accessible
66
+ via `${containerEnv:KEY}` in `devcontainer.json → remoteEnv` so VS Code settings and
67
+ extensions can reference them.
68
+
69
+ **Why this priority**: Without a `remoteEnv` entry, VS Code extensions that read `process.env`
70
+ at startup may not see the variable, even though the container process will.
71
+
72
+ **Independent Test**: Set a compose-stack env variable, run `regen`, and confirm
73
+ `devcontainer.json → remoteEnv` includes `KEY: ${containerEnv:KEY}` alongside the
74
+ `docker-compose.yml` entry.
75
+
76
+ **Acceptance Scenarios**:
77
+
78
+ 1. **Given** `env: {DB_URL: postgres://localhost/dev}` on a compose stack, **When** generation runs, **Then** `devcontainer.json` contains `remoteEnv.DB_URL: ${containerEnv:DB_URL}`.
79
+
80
+ ---
81
+
82
+ ## Overview
83
+
84
+ Refine project-file environment semantics so compose-based projects do not
85
+ embed resolved env values directly in generated `docker-compose.yml` or
86
+ `devcontainer.json`.
87
+
88
+ At the same time, rename the project-file field
89
+ `customizations.environment` to `customizations.envTemplate` to make its
90
+ purpose explicit: it writes template variables to `.env.example`, not runtime
91
+ container environment.
92
+
93
+ ## Behavior
94
+
95
+ ### `env:` on `stack: compose`
96
+
97
+ For compose-targeted project env entries:
98
+
99
+ 1. Materialize concrete values into `.devcontainer/.env`
100
+ 2. Write `docker-compose.yml -> services.devcontainer.environment.KEY: ${KEY}`
101
+ 3. Write `devcontainer.json -> remoteEnv.KEY: ${containerEnv:KEY}`
102
+
103
+ This keeps generated config free of resolved secret values while still making
104
+ the variables available inside the devcontainer.
105
+
106
+ ### Value Resolution
107
+
108
+ - literals are written as-is to `.devcontainer/.env`
109
+ - `${NAME}` resolves from the repository root `.env` when present
110
+ - `${NAME:-default}` resolves from the repository root `.env`, otherwise uses
111
+ the inline default
112
+ - unresolved `${NAME}` values are omitted from `.devcontainer/.env` so shell
113
+ environment fallback remains possible
114
+
115
+ ### `env:` on `stack: plain`
116
+
117
+ No change: values still land directly in `devcontainer.json -> remoteEnv`.
118
+
119
+ ## `customizations.envTemplate`
120
+
121
+ - `customizations.envTemplate` is the canonical project-file field for values
122
+ that should be written to `.env.example`
123
+ - `customizations.environment` is retained as a deprecated backward-compatible
124
+ alias
125
+ - serializers should emit `envTemplate`
126
+
127
+ ## Non-Goals
128
+
129
+ - no change to `.devcontainer/custom/environment.env`
130
+ - no support for targeting arbitrary compose sidecar services from `env:`
@@ -0,0 +1,235 @@
1
+ # Feature Specification: Overlay Parameters with Safe Substitution
2
+
3
+ **Feature Branch**: `011-overlay-parameters`
4
+ **Created**: 2026-03-30
5
+ **Status**: Final
6
+ **Input**: Issue — Introduce overlay parameters with safe, namespaced substitution — no conflicts with Docker/shell/VS Code
7
+
8
+ ## Review & Approval _(mandatory before implementation)_
9
+
10
+ - **Spec Path**: `docs/specs/011-overlay-parameters/spec.md`
11
+ - **Commit Status**: Committed
12
+ - **Review Status**: APPROVED
13
+ - **Implementation Gate**: No implementation code may begin until this spec is committed and reviewed.
14
+
15
+ ## Summary
16
+
17
+ Add first-class **parameters** to overlays so users can configure environment-specific values
18
+ (credentials, database names, ports, paths) without forking overlays or hand-editing generated
19
+ files.
20
+
21
+ Parameters use the `{{cs.PARAM_NAME}}` substitution syntax, which does not collide with Docker
22
+ Compose (`${VAR}`), shell (`$VAR`, `${VAR}`), VS Code (`${localWorkspaceFolder}`), or GitHub
23
+ Actions (`${{ }}`).
24
+
25
+ This is **parameter substitution only** — no loops, no conditionals, no embedded logic.
26
+ If `string.replace()` can't do it, it doesn't belong here.
27
+
28
+ ---
29
+
30
+ ## Design
31
+
32
+ ### Syntax
33
+
34
+ ```
35
+ {{cs.PARAM_NAME}}
36
+ ```
37
+
38
+ - **Safe**: does not collide with `${VAR}` (Docker/shell), `${env:VAR}` (VS Code), or `${{ }}` (GitHub Actions)
39
+ - **Consistent**: extends the existing `{{parameters.<key>.id}}` preset convention
40
+ - **Explicit**: clearly owned by container-superposition
41
+ - **Simple**: resolved by a single `string.replace()` regex, no parser needed
42
+
43
+ ### Overlay parameter declarations (`overlay.yml`)
44
+
45
+ Overlays declare parameters in `overlay.yml`:
46
+
47
+ ```yaml
48
+ id: postgres
49
+ name: PostgreSQL
50
+ category: database
51
+ parameters:
52
+ POSTGRES_DB:
53
+ description: Database name
54
+ default: app
55
+ POSTGRES_USER:
56
+ description: Database user
57
+ default: postgres
58
+ POSTGRES_PASSWORD:
59
+ description: Database password
60
+ default: postgres
61
+ sensitive: true
62
+ POSTGRES_PORT:
63
+ description: Host-mapped port
64
+ default: '5432'
65
+ ```
66
+
67
+ Fields:
68
+
69
+ - `description` (required) — human-readable explanation shown in interactive prompts
70
+ - `default` (optional) — default value; absence marks the parameter as _required_
71
+ - `sensitive` (optional, boolean) — indicates secrets; hidden in interactive prompts and redacted from plan output
72
+
73
+ ### Usage in overlay files
74
+
75
+ Overlay patches and compose files reference parameters using `{{cs.PARAM_NAME}}`:
76
+
77
+ ```json
78
+ {
79
+ "remoteEnv": {
80
+ "DATABASE_URL": "postgres://{{cs.POSTGRES_USER}}:{{cs.POSTGRES_PASSWORD}}@postgres:5432/{{cs.POSTGRES_DB}}"
81
+ }
82
+ }
83
+ ```
84
+
85
+ ```yaml
86
+ # docker-compose.yml — generation-time substitution coexists with Docker runtime substitution
87
+ services:
88
+ postgres:
89
+ environment:
90
+ POSTGRES_DB: '{{cs.POSTGRES_DB}}'
91
+ POSTGRES_USER: '{{cs.POSTGRES_USER}}'
92
+ POSTGRES_PASSWORD: '{{cs.POSTGRES_PASSWORD}}'
93
+ ports:
94
+ - '${POSTGRES_PORT:-{{cs.POSTGRES_PORT}}}:5432'
95
+ ```
96
+
97
+ ### Parameters in `superposition.yml`
98
+
99
+ ```yaml
100
+ overlays:
101
+ - postgres
102
+ - redis
103
+
104
+ parameters:
105
+ POSTGRES_DB: myapp
106
+ POSTGRES_USER: veggerby
107
+ REDIS_PORT: '6380'
108
+ ```
109
+
110
+ ### Resolution order (highest wins)
111
+
112
+ 1. CLI overrides (`--param POSTGRES_DB=foo`)
113
+ 2. Project file (`superposition.yml` `parameters:` section)
114
+ 3. Overlay defaults (`overlay.yml` `parameters[KEY].default`)
115
+
116
+ ### Validation rules
117
+
118
+ | Condition | Behaviour |
119
+ | ---------------------------------------------------------- | ------------------------------------- |
120
+ | Missing required parameter (no default, no value supplied) | **Hard error** before generation |
121
+ | Unknown parameter (not declared by any selected overlay) | **Warning** (proceed) |
122
+ | Unresolved `{{cs.*}}` in final output | **Hard error** (catch-all safety net) |
123
+
124
+ ### Pass-through guarantee
125
+
126
+ The substitution engine MUST NOT touch:
127
+
128
+ - Docker Compose expressions: `${VAR}`, `${VAR:-default}`, `$VAR`
129
+ - VS Code/devcontainer variables: `${localWorkspaceFolder}`, `${containerWorkspaceFolder}`, `${env:VAR}`
130
+ - GitHub Actions expressions: `${{ github.* }}`
131
+ - Shell variables in scripts: `$FOO`, `${FOO}`, `${FOO:-default}`
132
+
133
+ Only tokens matching exactly `{{cs.[A-Z0-9_]+}}` are substituted.
134
+
135
+ ---
136
+
137
+ ## Implementation Scope
138
+
139
+ ### Types (`tool/schema/types.ts`)
140
+
141
+ ```typescript
142
+ export interface OverlayParameterDefinition {
143
+ description: string;
144
+ default?: string;
145
+ sensitive?: boolean;
146
+ }
147
+ ```
148
+
149
+ Add to `OverlayMetadata`:
150
+
151
+ ```typescript
152
+ parameters?: Record<string, OverlayParameterDefinition>;
153
+ ```
154
+
155
+ Add to `ProjectConfigSelection`:
156
+
157
+ ```typescript
158
+ parameters?: Record<string, string>;
159
+ ```
160
+
161
+ Add to `QuestionnaireAnswers`:
162
+
163
+ ```typescript
164
+ overlayParameters?: Record<string, string>;
165
+ ```
166
+
167
+ ### Parameter engine (`tool/utils/parameters.ts`)
168
+
169
+ - `collectOverlayParameters(overlayIds, allOverlayDefs)` — collect all declared parameters from selected overlays with their defaults
170
+ - `resolveParameters(declared, supplied)` — apply resolution order, return resolved map and errors
171
+ - `substituteParameters(content, resolved)` — replace `{{cs.KEY}}` tokens in a string
172
+ - `validateFinalContent(content)` — error if any `{{cs.*}}` remain after substitution
173
+
174
+ ### Composer (`tool/questionnaire/composer.ts`)
175
+
176
+ After all overlay files are read and before they are written to disk:
177
+
178
+ 1. Collect parameter declarations from selected overlays
179
+ 2. Merge with `answers.overlayParameters` values
180
+ 3. Validate — error on missing required parameters
181
+ 4. Apply substitution to all file content strings (devcontainer.json, docker-compose.yml, .env.example, scripts)
182
+ 5. Validate — error on any unresolved `{{cs.*}}` tokens remaining in output
183
+
184
+ ### Project config (`tool/schema/project-config.ts`)
185
+
186
+ Parse `parameters:` YAML map as `Record<string, string>` (string values only).
187
+ Propagate to `selection.parameters` → `answers.overlayParameters`.
188
+
189
+ ### Init (`scripts/init.ts`)
190
+
191
+ When overlay declares parameters, interactive questionnaire prompts for values.
192
+ Sensitive parameters use masked input. Pre-filled with defaults.
193
+
194
+ ---
195
+
196
+ ## Non-goals
197
+
198
+ - Conditional logic (`{{if ...}}`)
199
+ - Loops or iteration
200
+ - Programmable overlays or JS execution
201
+ - Dynamic file generation
202
+ - Templating engine integration (Handlebars, Jinja, EJS, etc.)
203
+
204
+ ---
205
+
206
+ ## User Scenarios & Testing _(mandatory)_
207
+
208
+ ### User Story 1 — Postgres with custom database name (P1)
209
+
210
+ A user scaffolds a compose stack with the postgres overlay and wants their database named `myapp`
211
+ instead of the default `devdb`.
212
+
213
+ **Acceptance scenarios**:
214
+
215
+ 1. **Given** a `superposition.yml` with `parameters: { POSTGRES_DB: myapp }`, **When** generation runs, **Then** the generated `.devcontainer/docker-compose.yml` and `remoteEnv` in `devcontainer.json` reference `myapp` instead of `devdb`.
216
+ 2. **Given** an overlay with a required parameter (no default), **When** generation is run without providing the parameter value, **Then** the tool exits with a clear error message before writing any files.
217
+ 3. **Given** generated files contain no `{{cs.*}}` tokens, **When** output is validated, **Then** no error is raised and Docker Compose `${VAR}` expressions are preserved unmodified.
218
+ 4. **Given** a user runs `init` interactively with the postgres overlay, **When** the questionnaire reaches parameters, **Then** the user is prompted for each declared parameter with the default pre-filled.
219
+
220
+ ### User Story 2 — Sensitive parameter (P2)
221
+
222
+ A user provides a database password via parameter. The password must not appear in plan output in cleartext.
223
+
224
+ **Acceptance scenarios**:
225
+
226
+ 1. **Given** a parameter has `sensitive: true`, **When** the plan command shows parameter values, **Then** the value is displayed as `***`.
227
+ 2. **Given** a parameter has `sensitive: true`, **When** the interactive questionnaire prompts for it, **Then** the input is masked.
228
+
229
+ ### User Story 3 — Unknown parameter warning (P3)
230
+
231
+ A user adds a parameter in `superposition.yml` that is not declared by any selected overlay.
232
+
233
+ **Acceptance scenarios**:
234
+
235
+ 1. **Given** `parameters: { UNKNOWN_PARAM: foo }` in `superposition.yml`, **When** generation runs, **Then** a warning is printed but generation succeeds.
@@ -1,43 +1,127 @@
1
- # Shared Overlay Configurations
1
+ # Shared Overlay Fragments
2
2
 
3
- This directory contains shared configuration fragments that can be imported by multiple overlays to reduce duplication and ensure consistency.
3
+ This directory contains reusable configuration fragments that can be imported by multiple overlays to reduce duplication and ensure consistency.
4
4
 
5
5
  ## Structure
6
6
 
7
7
  ```
8
8
  .shared/
9
- ├── otel/ # OpenTelemetry configurations
10
- ├── compose/ # Docker Compose patterns (healthchecks, etc.)
11
- └── vscode/ # VS Code extension sets
9
+ ├── otel/ # OpenTelemetry configurations
10
+ ├── instrumentation.env # OTEL SDK env vars for instrumentation
11
+ └── otel-base-config.yaml # Base OTEL collector pipeline config
12
+ ├── compose/ # Docker Compose patterns
13
+ │ ├── nvidia-gpu-devcontainer.yml # NVIDIA GPU passthrough for the devcontainer service
14
+ │ └── common-healthchecks.md # Standard healthcheck patterns (reference — not importable)
15
+ └── vscode/ # VS Code extension sets
16
+ └── recommended-extensions.json # Commonly recommended extensions (devcontainer patch)
12
17
  ```
13
18
 
19
+ ## Fragment Catalogue
20
+
21
+ ### `otel/instrumentation.env`
22
+
23
+ **Purpose:** Common OpenTelemetry SDK environment variables for services that send telemetry to an OTEL collector.
24
+
25
+ **Provides:**
26
+
27
+ - `OTEL_SERVICE_NAME` — service identifier
28
+ - `OTEL_EXPORTER_OTLP_ENDPOINT` — OTLP collector endpoint
29
+ - `OTEL_EXPORTER_OTLP_PROTOCOL` — transport protocol (grpc)
30
+ - `OTEL_RESOURCE_ATTRIBUTES` — deployment metadata
31
+ - `OTEL_TRACES_SAMPLER`, `OTEL_TRACES_EXPORTER` — trace configuration
32
+ - `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER` — metrics and log exporters
33
+
34
+ **Imported by:** `otel-collector`, `prometheus`, `jaeger`
35
+
36
+ **Merge type:** `.env` — appended to `.env.example` with a `# from .shared/otel/instrumentation.env` comment
37
+
38
+ ---
39
+
40
+ ### `otel/otel-base-config.yaml`
41
+
42
+ **Purpose:** Base OpenTelemetry Collector receiver and pipeline configuration — OTLP receivers, batch processor, and logging exporter.
43
+
44
+ **Merge type:** `.yaml` — deep-merged into `devcontainer.json` patch
45
+
46
+ ---
47
+
48
+ ### `compose/nvidia-gpu-devcontainer.yml`
49
+
50
+ **Purpose:** Adds the `deploy.resources.reservations.devices` block to the `devcontainer` service, giving the devcontainer itself direct NVIDIA GPU access. This enables GPU-accelerated tooling (`torch`, `tensorflow`, CUDA CLIs, `nvidia-smi`) to work directly in the dev environment.
51
+
52
+ **Format:** Docker Compose service fragment (services.devcontainer only).
53
+
54
+ **Merge type:** `compose_imports:` — deep-merged into the final `docker-compose.yml` before the overlay's own `docker-compose.yml`.
55
+
56
+ **Imported by:** `ollama`
57
+
58
+ **Prerequisites:** NVIDIA Container Toolkit must be installed on the host.
59
+
60
+ ---
61
+
62
+ ### `compose/common-healthchecks.md`
63
+
64
+ **Purpose:** Reference library of standard Docker Compose healthcheck patterns for common services (HTTP, PostgreSQL, Redis, MongoDB, MySQL).
65
+
66
+ **Note:** This is a `.md` file (documentation only) — it cannot be imported via `overlay.yml` `imports:`. Copy the relevant pattern directly into your overlay's `docker-compose.yml`.
67
+
68
+ ---
69
+
70
+ ### `vscode/recommended-extensions.json`
71
+
72
+ **Purpose:** A curated set of VS Code extensions commonly useful across many overlays (spell checking, error lens, GitLens, EditorConfig, Prettier, Docker, YAML, Markdown).
73
+
74
+ **Format:** Valid devcontainer patch — `customizations.vscode.extensions` array.
75
+
76
+ **Merge type:** `.json` — deep-merged into `devcontainer.json` patch
77
+
78
+ ---
79
+
14
80
  ## Usage
15
81
 
16
- Overlays can import shared files by adding them to the `imports` field in `overlay.yml`:
82
+ Reference shared devcontainer fragments in `overlay.yml` via the `imports` field:
17
83
 
18
84
  ```yaml
19
- id: prometheus
85
+ id: my-overlay
20
86
  imports:
21
- - .shared/otel/otel-base-config.yaml
22
- - .shared/compose/common-healthchecks.yml
87
+ - .shared/otel/instrumentation.env
88
+ - .shared/vscode/recommended-extensions.json
89
+ ```
90
+
91
+ Reference shared docker-compose fragments via the `compose_imports` field:
92
+
93
+ ```yaml
94
+ id: my-overlay
95
+ compose_imports:
96
+ - .shared/compose/nvidia-gpu-devcontainer.yml
23
97
  ```
24
98
 
25
- ## Benefits
99
+ **Rules:**
100
+
101
+ - All paths must begin with `.shared/`
102
+ - Paths are relative to `overlays/`
103
+ - `imports` fragments are applied in declaration order, then the overlay's own `devcontainer.patch.json` (overlay wins on conflict)
104
+ - `compose_imports` fragments are deep-merged into `docker-compose.yml` before the overlay's own `docker-compose.yml` (overlay wins on conflict)
105
+ - `compose_imports` files must be `.yml` or `.yaml`
106
+
107
+ ## Creating New Fragments
108
+
109
+ 1. Choose the right subdirectory (`otel/`, `compose/`, `vscode/`, or create a new one with a clear name)
110
+ 2. Use a descriptive file name — one concern per file
111
+ 3. For `.json` and `.yaml` fragments, ensure the content is valid devcontainer patch format
112
+ 4. Add a comment at the top explaining what the fragment does
113
+ 5. Update this README with the new fragment's details and which overlays import it
26
114
 
27
- - **DRY (Don't Repeat Yourself)**: Common patterns defined once
28
- - **Consistency**: All overlays using the same shared config stay in sync
29
- - **Maintainability**: Update shared config once, all overlays benefit
30
- - **Best Practices**: Shared configs embody proven patterns
115
+ ## Downstream Impact
31
116
 
32
- ## Creating Shared Configs
117
+ Any change to a shared fragment affects every overlay that imports it. Before editing:
33
118
 
34
- 1. Identify common patterns across overlays
35
- 2. Extract to appropriate `.shared/` subdirectory
36
- 3. Update overlays to import the shared file
37
- 4. Test that imports work correctly
119
+ - Check the "Imported by" section above for the fragment you're modifying
120
+ - Run `npm test` and `container-superposition doctor` after changes
121
+ - Consider whether the change should apply to all importers, or whether specific overlays need to be updated
38
122
 
39
123
  ## Import Resolution
40
124
 
41
125
  - Imports are resolved relative to the `overlays/` directory
42
- - Shared files are merged into the overlay during composition
43
- - Files are applied in the order they are listed
126
+ - Path traversal (`../`, absolute paths, non-`.shared/` prefixes) is rejected at composition time
127
+ - Missing or unsupported file types cause generation to fail with a message naming the overlay and the bad reference
@@ -0,0 +1,60 @@
1
+ # Common Docker Compose Healthcheck Patterns
2
+
3
+ Reference library of standard healthcheck patterns for common services. This is a **documentation file only** — it cannot be imported via `overlay.yml` `imports:` because it is not a devcontainer patch.
4
+
5
+ Copy the relevant pattern directly into your overlay's `docker-compose.yml`.
6
+
7
+ ## HTTP
8
+
9
+ ```yaml
10
+ healthcheck:
11
+ test: ['CMD-SHELL', 'curl -f http://localhost:${PORT}/health || exit 1']
12
+ interval: 30s
13
+ timeout: 10s
14
+ retries: 3
15
+ start_period: 40s
16
+ ```
17
+
18
+ ## PostgreSQL
19
+
20
+ ```yaml
21
+ healthcheck:
22
+ test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-postgres}']
23
+ interval: 10s
24
+ timeout: 5s
25
+ retries: 5
26
+ start_period: 10s
27
+ ```
28
+
29
+ ## Redis
30
+
31
+ ```yaml
32
+ healthcheck:
33
+ test: ['CMD', 'redis-cli', 'ping']
34
+ interval: 10s
35
+ timeout: 5s
36
+ retries: 5
37
+ start_period: 10s
38
+ ```
39
+
40
+ ## MongoDB
41
+
42
+ ```yaml
43
+ healthcheck:
44
+ test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
45
+ interval: 10s
46
+ timeout: 5s
47
+ retries: 5
48
+ start_period: 10s
49
+ ```
50
+
51
+ ## MySQL
52
+
53
+ ```yaml
54
+ healthcheck:
55
+ test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
56
+ interval: 10s
57
+ timeout: 5s
58
+ retries: 5
59
+ start_period: 10s
60
+ ```
@@ -0,0 +1,22 @@
1
+ # Shared Docker Compose fragment: NVIDIA GPU passthrough for the devcontainer service.
2
+ #
3
+ # Adds the deploy.resources.reservations.devices block to the devcontainer service so
4
+ # GPU-accelerated tooling (torch, tensorflow, CUDA CLIs, etc.) works directly in the
5
+ # dev environment alongside any GPU-enabled sidecar services.
6
+ #
7
+ # Requirements: NVIDIA Container Toolkit must be installed on the host.
8
+ # https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
9
+ #
10
+ # Used by: ollama
11
+ # Import via compose_imports in overlay.yml:
12
+ # compose_imports:
13
+ # - .shared/compose/nvidia-gpu-devcontainer.yml
14
+ services:
15
+ devcontainer:
16
+ deploy:
17
+ resources:
18
+ reservations:
19
+ devices:
20
+ - driver: nvidia
21
+ count: all
22
+ capabilities: [gpu]
@@ -1,14 +1,18 @@
1
1
  {
2
- "description": "Commonly recommended VS Code extensions across overlays",
3
- "extensions": {
4
- "productivity": [
5
- "streetsidesoftware.code-spell-checker",
6
- "usernamehw.errorlens",
7
- "eamodio.gitlens"
8
- ],
9
- "formatting": ["editorconfig.editorconfig", "esbenp.prettier-vscode"],
10
- "docker": ["ms-azuretools.vscode-docker"],
11
- "yaml": ["redhat.vscode-yaml"],
12
- "markdown": ["yzhang.markdown-all-in-one", "davidanson.vscode-markdownlint"]
2
+ "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",
3
+ "customizations": {
4
+ "vscode": {
5
+ "extensions": [
6
+ "streetsidesoftware.code-spell-checker",
7
+ "usernamehw.errorlens",
8
+ "eamodio.gitlens",
9
+ "editorconfig.editorconfig",
10
+ "esbenp.prettier-vscode",
11
+ "ms-azuretools.vscode-docker",
12
+ "redhat.vscode-yaml",
13
+ "yzhang.markdown-all-in-one",
14
+ "davidanson.vscode-markdownlint"
15
+ ]
16
+ }
13
17
  }
14
18
  }
@@ -5,26 +5,11 @@ set -e
5
5
 
6
6
  echo "🔧 Setting up Alertmanager integration..."
7
7
 
8
- # Determine workspace root dynamically to support both /workspaces/* and /workspace layouts
9
- WORKSPACE_ROOT="${LOCAL_WORKSPACE_FOLDER:-$PWD}"
8
+ # Resolve the .devcontainer directory relative to this script.
9
+ # Scripts live at .devcontainer/scripts/, so .. is always .devcontainer/.
10
+ DEVCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
10
11
 
11
- # If the current root does not contain a .devcontainer, try common devcontainer locations
12
- if [ ! -d "$WORKSPACE_ROOT/.devcontainer" ]; then
13
- # Try to detect a workspace under /workspaces (compose templates)
14
- if [ -d "/workspaces" ]; then
15
- FIRST_WORKSPACE_DIR="$(find /workspaces -maxdepth 1 -mindepth 1 -type d 2>/dev/null | head -n 1)"
16
- if [ -n "$FIRST_WORKSPACE_DIR" ] && [ -d "$FIRST_WORKSPACE_DIR/.devcontainer" ]; then
17
- WORKSPACE_ROOT="$FIRST_WORKSPACE_DIR"
18
- fi
19
- fi
20
- fi
21
-
22
- # Fallback to /workspace if it exists and contains a .devcontainer (non-compose setups)
23
- if [ ! -d "$WORKSPACE_ROOT/.devcontainer" ] && [ -d "/workspace/.devcontainer" ]; then
24
- WORKSPACE_ROOT="/workspace"
25
- fi
26
-
27
- PROMETHEUS_CONFIG="$WORKSPACE_ROOT/.devcontainer/prometheus-prometheus.yml"
12
+ PROMETHEUS_CONFIG="$DEVCONTAINER_DIR/prometheus-prometheus.yml"
28
13
 
29
14
  # Check if Prometheus config exists
30
15
  if [ -f "$PROMETHEUS_CONFIG" ]; then