Skip to content

Promote env detection to chunk env init, remove sidecar env/build - #438

Draft
schurchleycci wants to merge 3 commits into
mainfrom
env-detect-top-level
Draft

Promote env detection to chunk env init, remove sidecar env/build#438
schurchleycci wants to merge 3 commits into
mainfrom
env-detect-top-level

Conversation

@schurchleycci

@schurchleycci schurchleycci commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

The thinking here: if we want to use dockerfiles as the basis for spinning up lots of sidecars, having a command to generate the dockerfile directly, rather than as a side effect of chunk sidecar env | chunk sidecar build --dir, may be a smoother experience.

  • Adds chunk env init as a new top-level command that detects a repository's tech stack and writes Dockerfile.test to --dir (default), or prints the environment spec as JSON (--format json). The detected spec is saved to .chunk/config.json for reuse by chunk sidecar setup.
  • Fixes a stale error message in validate.go that referenced chunk sidecar env build (a command that never existed); it now correctly suggests chunk sidecar sync.

Before / after

# Before
chunk sidecar env | chunk sidecar build --dir .

# After
chunk env init --dir .
docker build -f Dockerfile.test -t myapp:test .

Test plan

  • task test passes (acceptance + unit)
  • chunk env init writes Dockerfile.test and prints its path
  • chunk env init --format json prints the env spec to stdout
  • chunk env init --no-save skips writing .chunk/config.json
  • chunk sidecar setup still works (reuses cached spec from config)

🤖 Generated with Claude Code

schurchleycci and others added 2 commits July 14, 2026 15:29
Moves chunk sidecar env and chunk sidecar build into a new top-level
chunk env detect command with --format json|dockerfile. Detection is
no longer a sidecar-specific concern, and the docker build step is
removed from the CLI — callers run docker themselves.

Acceptance test renamed from sidecars_build_e2e_test.go to
env_detect_e2e_test.go; e2eRunBuild split into e2eRenderDockerfile
and e2eDockerBuild to make the two-step flow explicit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chunk env init now writes Dockerfile.test by default; --format json opts
into the JSON spec. This better reflects the intended use as a project
initialization step (detect stack, produce Dockerfile, cache to config)
rather than a pure inspection command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@schurchleycci schurchleycci changed the title Add chunk env init command Promote env detection to chunk env init, remove sidecar env/build Jul 14, 2026
Comment thread internal/cmd/sidecar.go
Example:
chunk sidecar env --dir . | chunk sidecar build --dir .`,
RunE: func(cmd *cobra.Command, _ []string) error {
if tag != "" && !validDockerTag.MatchString(tag) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're dropping chunk's tag validation here now that docker build is run by the user instead of by chunk. it'll still reject a bad tag, with its own error - but wasn't sure if it was intentional - just a ux thing i guess!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was intentional - under the assumption we may as well just have the user run docker build themselves

Comment thread harness/environment.py Outdated
prompt = f"""You are debugging an environment detection tool inside the chunk CLI.

`chunk sidecar env` analyses a repository, detects its tech stack, and writes a
`chunk env detect` analyses a repository, detects its tech stack, and writes a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err i might be missing this but i can not find the detect subcommand. naming mismatch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this was a naming mismatch - fixed now!

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants