Update init --codespaces to merge with existing devcontainer.json#7060
Merged
Update init --codespaces to merge with existing devcontainer.json#7060
Conversation
- Modified ensureDevcontainerConfig to check for existing devcontainer at default location - If .devcontainer/devcontainer.json exists, update it by merging gh-aw config - If no devcontainer exists, create at default location instead of subfolder - Update preserves existing name, image, extensions, features, and postCreateCommand - Added helper functions for merging extensions and features - Updated help text and success messages to reflect new behavior - Updated all tests to validate new behavior including merge scenarios - Manually tested both scenarios: new file creation and existing file update Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
reviewed
Dec 20, 2025
| VSCode: &DevcontainerVSCode{ | ||
| Extensions: []string{ | ||
| "GitHub.copilot", | ||
| "GitHub.copilot-chat", |
Copilot
AI
changed the title
[WIP] Update init command to enhance devcontainer file handling
Update init --codespaces to merge with existing devcontainer.json
Dec 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
init --codespacescommand previously created devcontainer.json in a subfolder (.devcontainer/gh-aw/) to avoid conflicts. This required users to manually merge configurations when a devcontainer already existed at the default location.Changes
ensureDevcontainerConfig()to check for existing devcontainer at.devcontainer/devcontainer.jsonfirst:latestExample
Existing devcontainer:
{ "name": "Python Project", "image": "mcr.microsoft.com/devcontainers/python:3.11", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} } }After
gh aw init --codespaces:{ "name": "Python Project", "image": "mcr.microsoft.com/devcontainers/python:3.11", "customizations": { "vscode": { "extensions": ["GitHub.copilot", "GitHub.copilot-chat"] }, "codespaces": { "repositories": { "org/repo": { "permissions": { "workflows": "write", ... } } } } }, "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers/features/github-cli:1": {}, "ghcr.io/devcontainers/features/copilot-cli:latest": {} } }Helper Functions
buildRepositoryPermissions()- constructs permissions map for current/additional reposmergeExtensions()- deduplicates extension arraysmergeFeatures()- merges feature maps, updates copilot-cli versionsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.