Skip to content

Commit 046a3dd

Browse files
skulidropekclaude
andcommitted
refactor(container): extract container definition into a dedicated package (#412)
Separate the container definition from the panel and the backend. - New leaf package @prover-coder-ai/docker-git-container owns the pure rendering layer (planFiles → Dockerfile/entrypoint.sh/docker-compose.yml, TemplateConfig, resolveCompose* helpers). Zero deps on shell/usecases/api/app. - packages/lib (backend) now depends on it and re-exports the moved symbols, keeping the @effect-template/lib public API unchanged. - Panel: removed the dead duplicate packages/app/src/lib (165 files), its @lib / @effect-template/lib aliases and unused dependency. The no-lib-imports ESLint rule now forbids the panel from importing the backend OR the container-definition package. No runtime behaviour change: generated container files are byte-identical, guaranteed by the unchanged property-based template test suite (moved to the new package). Dependency graph stays acyclic: container <- lib <- api. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e554ee8 commit 046a3dd

242 files changed

Lines changed: 1246 additions & 23720 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
"@prover-coder-ai/docker-git": patch
3+
"@effect-template/lib": patch
4+
---
5+
6+
Separate the container definition from the panel and the backend (issue #412).
7+
8+
The container definition — the pure layer that renders a project's `Dockerfile`,
9+
`entrypoint.sh` and `docker-compose.yml` from a `TemplateConfig` — has been
10+
extracted from the backend package (`@effect-template/lib`) into a new,
11+
dependency-free leaf package `@prover-coder-ai/docker-git-container`. The backend
12+
now depends on it and re-exports the moved symbols, so its public API is
13+
unchanged.
14+
15+
The panel (`@prover-coder-ai/docker-git`) no longer carries a duplicate copy of
16+
the container/backend logic: the dead `packages/app/src/lib` tree (165 files) and
17+
its now-unused `@lib` / `@effect-template/lib` aliases and dependency were
18+
removed. The `no-lib-imports` ESLint rule now forbids the panel from importing
19+
either the backend or the container-definition package, keeping the boundary
20+
enforced.
21+
22+
No runtime behaviour changes: the generated container files are byte-identical
23+
(guaranteed by the unchanged property-based template test suite, which moved to
24+
the new package).

bun.lock

Lines changed: 49 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"workspaces": [
88
"packages/api",
99
"packages/app",
10+
"packages/container",
1011
"packages/docker-git-session-sync",
1112
"packages/lib",
1213
"packages/terminal"

packages/api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"type": "module",
88
"packageManager": "bun@1.3.11",
99
"scripts": {
10-
"prebuild": "bun run --cwd ../terminal build && bun run --cwd ../lib build",
10+
"prebuild": "bun run --cwd ../terminal build && bun run --cwd ../container build && bun run --cwd ../lib build",
1111
"build": "tsc -p tsconfig.json",
1212
"dev": "tsc -p tsconfig.json --watch",
1313
"prestart": "bun run build",
1414
"start": "bun dist/src/main.js",
15-
"pretypecheck": "bun run --cwd ../terminal build && bun run --cwd ../lib build",
15+
"pretypecheck": "bun run --cwd ../terminal build && bun run --cwd ../container build && bun run --cwd ../lib build",
1616
"typecheck": "tsc --noEmit -p tsconfig.json",
1717
"lint": "eslint .",
18-
"pretest": "bun run --cwd ../terminal build && bun run --cwd ../lib build",
18+
"pretest": "bun run --cwd ../terminal build && bun run --cwd ../container build && bun run --cwd ../lib build",
1919
"test": "vitest run"
2020
},
2121
"dependencies": {

packages/app/eslint/no-lib-imports.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// @ts-check
22

3-
const bannedPackageName = "@effect-template/lib"
3+
// CHANGE: forbid the panel from importing BOTH the backend and the container-definition packages (issue #412)
4+
// WHY: packages/app is the panel; container orchestration lives in @effect-template/lib (backend) and
5+
// container definition in @prover-coder-ai/docker-git-container. The panel must reach them only via the API client.
6+
// REF: issue-412
7+
const bannedPackageNames = ["@effect-template/lib", "@prover-coder-ai/docker-git-container"]
48
const bannedLocalAlias = "@lib"
59

610
/** @param {string} value */
@@ -38,7 +42,7 @@ const isFrontendSurfaceFile = (filePath) => {
3842

3943
/** @param {string} value */
4044
const isDirectLibImport = (value) =>
41-
value === bannedPackageName || value.startsWith(`${bannedPackageName}/`)
45+
bannedPackageNames.some((name) => value === name || value.startsWith(`${name}/`))
4246

4347
/**
4448
* @param {unknown} value
@@ -198,12 +202,12 @@ export const noLibImportsRule = {
198202
type: "problem",
199203
docs: {
200204
description:
201-
"forbid direct imports, re-exports, and require calls from legacy lib surfaces inside package/app frontend surfaces and tests"
205+
"forbid direct imports, re-exports, and require calls from the backend (@effect-template/lib) or container-definition (@prover-coder-ai/docker-git-container) packages inside package/app frontend surfaces and tests"
202206
},
203207
schema: [],
204208
messages: {
205209
noLibImport:
206-
"Direct import or require '{{source}}' from legacy lib surfaces is forbidden in package/app frontend surfaces and tests. Use the API client or a local app adapter instead."
210+
"Direct import or require '{{source}}' from the backend (@effect-template/lib) or container-definition (@prover-coder-ai/docker-git-container) packages is forbidden in package/app frontend surfaces and tests. Use the API client or a local app adapter instead."
207211
}
208212
},
209213
create: createRuleListener

packages/app/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"doc": "doc"
1414
},
1515
"scripts": {
16-
"prebuild": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
16+
"prebuild": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
1717
"build": "bun run build:app && bun run build:docker-git",
1818
"build:app": "vite build --ssr src/app/main.ts",
1919
"build:web": "vite build --config vite.web.config.ts",
@@ -22,13 +22,13 @@
2222
"dev": "vite build --watch --ssr src/app/main.ts",
2323
"dev:web": "vite --config vite.web.config.ts",
2424
"serve:web": "bun scripts/serve-dist-web.mjs",
25-
"prelint": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
25+
"prelint": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
2626
"lint": "NODE_OPTIONS=--max-old-space-size=4096 PATH=../../scripts:$PATH vibecode-linter src/",
2727
"lint:tests": "NODE_OPTIONS=--max-old-space-size=4096 PATH=../../scripts:$PATH vibecode-linter tests/",
2828
"lint:effect": "NODE_OPTIONS=--max-old-space-size=4096 PATH=../../scripts:$PATH eslint --config eslint.effect-ts-check.config.mjs .",
29-
"prebuild:docker-git": "bun install --cwd ../.. && bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
29+
"prebuild:docker-git": "bun install --cwd ../.. && bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
3030
"build:docker-git": "vite build --config vite.docker-git.config.ts",
31-
"prebuild:docker-git:reuse-install": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
31+
"prebuild:docker-git:reuse-install": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
3232
"build:docker-git:reuse-install": "vite build --config vite.docker-git.config.ts",
3333
"check": "bun run typecheck",
3434
"clone": "bun run build:docker-git && bun dist/src/docker-git/main.js clone",
@@ -37,9 +37,9 @@
3737
"list": "bun run build:docker-git && bun dist/src/docker-git/main.js ps",
3838
"preview:web": "vite preview --config vite.web.config.ts",
3939
"start": "bun run build:docker-git && bun dist/src/docker-git/main.js",
40-
"pretest": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
40+
"pretest": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
4141
"test": "bun run lint:tests && vitest run",
42-
"pretypecheck": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build && bun run --cwd ../lib build",
42+
"pretypecheck": "bun run --cwd ../docker-git-session-sync build && bun run --cwd ../terminal build",
4343
"typecheck": "tsc --noEmit"
4444
},
4545
"repository": {
@@ -87,7 +87,6 @@
8787
},
8888
"devDependencies": {
8989
"@biomejs/biome": "^2.5.0",
90-
"@effect-template/lib": "workspace:*",
9190
"@effect/eslint-plugin": "^0.3.2",
9291
"@effect/language-service": "latest",
9392
"@effect/vitest": "^0.29.0",

packages/app/src/docker-git/api-terminal-codec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ type RawTerminalSession = {
1717

1818
const isTerminalSessionStatus = (
1919
value: string
20-
): value is ApiTerminalSession["status"] =>
21-
["ready", "attached", "exited", "failed"].includes(value)
20+
): value is ApiTerminalSession["status"] => ["ready", "attached", "exited", "failed"].includes(value)
2221

2322
const readOptionalNumber = (value: JsonValue | undefined): number | undefined =>
2423
typeof value === "number" ? value : undefined

packages/app/src/docker-git/browser-frontend-state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const browserFrontendRevisionInputs: ReadonlyArray<string> = [
5757
"packages/app/vite.web.config.ts",
5858
"packages/app/scripts/serve-dist-web.mjs",
5959
"packages/app/src/docker-git",
60-
"packages/app/src/lib",
6160
"packages/app/src/shared",
6261
"packages/app/src/ui",
6362
"packages/app/src/web"

packages/app/src/docker-git/controller-docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const controllerContainerName = process.env["DOCKER_GIT_API_CONTAINER_NAM
3737

3838
const inspectNetworksTemplate = String
3939
.raw`{{range $k,$v := .NetworkSettings.Networks}}{{printf "%s=%s\n" $k $v.IPAddress}}{{end}}`
40-
const inspectEnvTemplate = String.raw`{{range .Config.Env}}{{println .}}{{end}}`
40+
const inspectEnvTemplate = "{{range .Config.Env}}{{println .}}{{end}}"
4141

4242
const controllerBootstrapError = (message: string): ControllerBootstrapError => ({
4343
_tag: "ControllerBootstrapError",

packages/app/src/docker-git/controller-image-revision.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { type ControllerRuntime, runDockerCapture, runDockerCaptureWithFailureOu
99
import { parseControllerRevisionLabelOutput } from "./controller-revision.js"
1010
import type { ControllerBootstrapError } from "./host-errors.js"
1111

12-
const inspectControllerRevisionLabelTemplate = String
13-
.raw`{{ index .Config.Labels "io.prover-coder-ai.docker-git.controller-rev" }}`
12+
const inspectControllerRevisionLabelTemplate =
13+
"{{ index .Config.Labels \"io.prover-coder-ai.docker-git.controller-rev\" }}"
1414
const missingImageInspectionPatterns: ReadonlyArray<RegExp> = [/No such image/iu, /No such object/iu]
1515

1616
/**

0 commit comments

Comments
 (0)