Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Adds a --codespace flag to gh aw init that creates or updates .devcontainer/devcontainer.json with GitHub Codespace token permissions for the current repository and read access to githubnext/gh-aw releases.

Changes

  • New flag: Added --codespace to init command
  • Devcontainer management (pkg/cli/codespace_init.go):
    • Detects existing devcontainer.json in .devcontainer/ or repository root
    • Creates basic config with mcr.microsoft.com/devcontainers/universal:2 if none exists
    • Preserves all existing fields (name, features, customizations) using custom JSON marshaling
    • Merges permissions via mergePermissions() helper to avoid overwriting existing values
  • Permission configuration:
    • Current repo (detected via GetCurrentRepoSlug()): write access for actions, contents, workflows, issues, pull requests, discussions
    • githubnext/gh-aw: read access for contents and metadata
  • Tests: Comprehensive coverage for creation, updates, idempotency, and field preservation

Usage

gh aw init --codespace

Generates:

{
  "image": "mcr.microsoft.com/devcontainers/universal:2",
  "customizations": {
    "codespaces": {
      "repositories": {
        "owner/repo": {
          "permissions": {
            "actions": "write",
            "contents": "write",
            "workflows": "write",
            "issues": "write",
            "pull-requests": "write",
            "discussions": "write"
          }
        },
        "githubnext/gh-aw": {
          "permissions": {
            "contents": "read",
            "metadata": "read"
          }
        }
      }
    }
  }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy (dns block)
  • go.uber.org
    • Triggering command: /update-job-proxy /update-job-proxy (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy (dns block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add a flag "--codespace" to the "init" command that tries to optimize the setup for github codespaces.

  • detect if a devcontainer.json file is present, if not create a basic one.
  • added permissions for the codespace token to write actions
{
    "image": "mcr.microsoft.com/devcontainers/universal:2",
    "customizations": {
        "codespaces": {
            "repositories": {
                "OWNER/REPO: { # update
                    "permissions": {
                        "actions": "write",
                        "contents": "write",
                        "workflows": "write",
                        "issues": "write",
                        "pull-requests": "write",
                        "discussions": "write"
                    }
                }
            }
        }
    }
}

Also give permissions to read releases from the githubnext/gh-aw repository so that the extension can be downloaded in the future.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 3, 2025 17:25
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add codespace flag to init command for optimization Add --codespace flag to init command for devcontainer.json generation Dec 3, 2025
Copilot AI requested a review from pelikhan December 3, 2025 17:47
@pelikhan pelikhan closed this Dec 3, 2025
@pelikhan pelikhan deleted the copilot/add-codespace-init-flag branch December 4, 2025 20:42
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