-
Notifications
You must be signed in to change notification settings - Fork 34
Add --codespaces flag to init command for devcontainer generation with additional repository support #5966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the codespaces flag takes a list of additional repository specs for which read permissions will be given |
- Added --codespace flag to init command - Created ensureDevcontainerConfig function in pkg/cli/devcontainer.go - Generates devcontainer.json with universal image - Configures workflows: write permission for current repo - Adds read access to githubnext/gh-aw releases - Pre-installs gh aw extension CLI and @github/copilot via postCreateCommand - Updated InitRepository function to support codespace parameter - Added comprehensive unit tests for devcontainer functionality - Updated existing init tests to include new codespace parameter Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
All tests pass, linting and formatting complete Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the permissions for the current repo should be : all the default codespaces permissions + workspace: write |
- Changed --codespace from boolean to StringSlice flag - Flag now accepts comma-separated list of repository specs - Additional repositories get contents: read permissions - Updated help text and examples to show usage - Updated InitRepository signature to accept []string instead of bool - Updated ensureDevcontainerConfig to process additional repos - Added new test for additional repository configuration - Updated all existing tests to match new signature Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated! The |
|
@copilot the other repos should have default codespace permissions but readonly + workflow read |
- Current repo now gets contents:write, pull-requests:write, workflows:write - Previously only had workflows:write - Updated help text to reflect default Codespaces permissions - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated! The current repository now receives default Codespaces permissions (contents:write, pull-requests:write) plus workflows:write. Previously it only had workflows:write. Commit: ce22062 |
- Additional repos now get contents:read, pull-requests:read, workflows:read - Previously only had contents:read - Updated help text to reflect default Codespaces read permissions - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the command must create a devcontainer.json ina non-default location (subfolder) so that it does not override any existing devcontainer.json |
- Changed location from .devcontainer/devcontainer.json to .devcontainer/gh-aw/devcontainer.json - This prevents overriding existing devcontainer configurations - Updated help text and success messages to reflect new location - Updated all tests to check new path - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated! The devcontainer.json is now created at |
|
@copilot also give actions:write to current repo |
- Changed actions permission from read to write for current repository - Current repo now has: actions:write, contents:write, discussions:read, issues:read, pull-requests:write, workflows:write - Additional repos still have: actions:read, contents:read, discussions:read, issues:read, pull-requests:read, workflows:read - Updated help text to reflect actions:write - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot if the user gives an org, validate it is the same org as the current repo |
- Validates that when full owner/repo format is used, the owner matches current repo - Returns error if repository is from different organization - Maintains backward compatibility with full owner/repo syntax when owner matches - Added test TestEnsureDevcontainerConfigWithOwnerValidation - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
... Added validation! When using full |
|
@copilot add the |
- Updated Makefile recompile target to include --codespaces flag - Uses --codespaces , to create devcontainer with current repo only - This ensures devcontainer.json is created during build process - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added! The |
Makefile
Outdated
| .PHONY: recompile | ||
| recompile: sync-templates build | ||
| ./$(BINARY_NAME) init | ||
| ./$(BINARY_NAME) init --codespaces , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add support for no argument with --codespaces which means "current repo only"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented! The --codespaces flag now supports being used without arguments for current repo only. Use --codespaces= (with equals sign but no value) to create devcontainer with just the current repository. The Makefile has been updated to use this syntax. Commit: b217ad1
- Changed --codespaces from StringSlice to String flag with NoOptDefVal - Flag now works with --codespaces= (no value) to create devcontainer for current repo only - Updated Makefile to use --codespaces= instead of --codespaces , - Added support for comma-separated repo names: --codespaces=repo1,repo2 - Updated help text and examples to show new syntax - Added test TestInitCommandWithCodespacesNoArgs - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot Flag syntax should be: --codespaces |
- Changed syntax to support: --codespaces, --codespaces repo, --codespaces repo,repo2 - Uses NoOptDefVal with space to allow flag without value - Trims spaces from repo string to handle NoOptDefVal marker - Updated Makefile to use --codespaces instead of --codespaces= - Updated help text and examples - Updated tests to verify NoOptDefVal is set correctly - All three syntaxes tested and working Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated! The flag now supports all three syntax patterns:
The Makefile now uses |
Add --codespaces flag to init command for devcontainer generation with additional repository support
Summary
Adds
--codespacesflag togh aw initfor generating devcontainer.json configured for agentic workflows in GitHub Codespaces.Changes
gh aw init --codespacescreates.devcontainer/gh-aw/devcontainer.json(in subfolder to avoid conflicts with existing devcontainer configurations)--codespaces- Current repo only (no value needed)--codespaces repo- Current repo + single additional repo--codespaces repo,repo2- Current repo + comma-separated list of additional reposowner/repoformat supported, but owner must match current repo's organizationrecompiletarget to automatically generate devcontainer during build processImplementation
pkg/cli/devcontainer.go: Core logic for devcontainer.json generation with support for additional repositories, includes documentation references, automatic owner extraction from git remote, and owner validationpkg/cli/init_command.go: String flag with NoOptDefVal for optional value supportpkg/cli/init.go: Integration into InitRepository flow with codespaceEnabled booleanMakefile: Uses--codespacesin recompile target to generate devcontainer during build.devcontainer/gh-aw/devcontainer.jsonto prevent overriding existing devcontainer configurationsUsage
Build Integration
The
make recompiletarget now includes the--codespacesflag:This ensures that
.devcontainer/gh-aw/devcontainer.jsonis automatically created during the build process with permissions configured for the current repository.Generated devcontainer.json
Location:
.devcontainer/gh-aw/devcontainer.json{ "name": "Agentic Workflows Development", "image": "mcr.microsoft.com/devcontainers/universal:latest", "customizations": { "codespaces": { "repositories": { "myorg/myrepo": { "permissions": { "actions": "write", "contents": "write", "discussions": "read", "issues": "read", "pull-requests": "write", "workflows": "write" } }, "myorg/repo1": { "permissions": { "actions": "read", "contents": "read", "discussions": "read", "issues": "read", "pull-requests": "read", "workflows": "read" } }, "myorg/repo2": { "permissions": { "actions": "read", "contents": "read", "discussions": "read", "issues": "read", "pull-requests": "read", "workflows": "read" } } } } }, "postCreateCommand": "curl -fsSL https://raw.githubusercontent.com/githubnext/gh-aw/refs/heads/main/install-gh-aw.sh | bash && npm install -g @github/copilot" }Permissions Reference
Permissions are configured according to GitHub Codespaces documentation:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.