From f6773c96277f0cc26ce788483c1998ecb31833df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:02:04 +0000 Subject: [PATCH 1/4] Initial plan From bb22d2141dbbb39d20edb32124182812d11afe54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:13:39 +0000 Subject: [PATCH 2/4] Fix HTTP 404 error when running gh aw init in codespaces by adding gh CLI fallback Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/commands.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index 5b29bc4b669..290eaa628c1 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "os/exec" "path/filepath" @@ -82,6 +83,20 @@ func downloadAgentFileFromGitHub(verbose bool) (string, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { + // Fall back to gh CLI for authenticated access (e.g., private repos in codespaces) + if resp.StatusCode == http.StatusNotFound && isGHCLIAvailable() { + commandsLog.Print("Unauthenticated download returned 404, trying gh CLI for authenticated access") + if verbose { + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Retrying download with gh CLI authentication...")) + } + if content, ghErr := downloadAgentFileViaGHCLI(ref); ghErr == nil { + patchedContent := patchAgentFileURLs(content, ref) + commandsLog.Printf("Successfully downloaded agent file via gh CLI (%d bytes)", len(patchedContent)) + return patchedContent, nil + } else { + commandsLog.Printf("gh CLI fallback failed: %v", ghErr) + } + } return "", fmt.Errorf("failed to download agent file: HTTP %d", resp.StatusCode) } @@ -118,6 +133,19 @@ func patchAgentFileURLs(content, ref string) string { return content } +// downloadAgentFileViaGHCLI downloads the agent file using the gh CLI with authentication. +// This is used as a fallback when the unauthenticated raw.githubusercontent.com download fails +// (e.g., for private repositories accessed from codespaces). +func downloadAgentFileViaGHCLI(ref string) (string, error) { + output, err := workflow.RunGH("Downloading agent file...", "api", + fmt.Sprintf("/repos/github/gh-aw/contents/.github/agents/agentic-workflows.agent.md?ref=%s", url.QueryEscape(ref)), + "--header", "Accept: application/vnd.github.raw") + if err != nil { + return "", fmt.Errorf("gh api download failed: %w", err) + } + return string(output), nil +} + func isGHCLIAvailable() bool { cmd := exec.Command("gh", "--version") return cmd.Run() == nil From 5a373d3818fe8591608569179012fd7ef9f79ee0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:30:07 +0000 Subject: [PATCH 3/4] Refactor: extract isRelease() function from inline check in downloadAgentFileFromGitHub Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/commands.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index 290eaa628c1..4554da90632 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -43,18 +43,21 @@ func GetVersion() string { return version } +// isRelease returns true if the current version is a release build +// (i.e. starts with "v", contains a dot, and is not dirty). +func isRelease() bool { + v := GetVersion() + return strings.HasPrefix(v, "v") && strings.Contains(v, ".") && !strings.Contains(v, "dirty") +} + // downloadAgentFileFromGitHub downloads the agentic-workflows.agent.md file from GitHub func downloadAgentFileFromGitHub(verbose bool) (string, error) { commandsLog.Print("Downloading agentic-workflows.agent.md from GitHub") // Determine the ref to use (tag for releases, main for dev builds) ref := "main" - currentVersion := GetVersion() - - // If version looks like a release tag (starts with v and contains dots), use it - isRelease := strings.HasPrefix(currentVersion, "v") && strings.Contains(currentVersion, ".") && !strings.Contains(currentVersion, "dirty") - if isRelease { - ref = currentVersion + if isRelease() { + ref = GetVersion() commandsLog.Printf("Using release tag: %s", ref) if verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Using release version: %s", ref))) From 8a5045758a89e8466e278ddb8f3e09f6ec9d6fd0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:44:38 +0000 Subject: [PATCH 4/4] Replace local isRelease() with workflow.IsRelease() for release detection Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/commands.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index 4554da90632..043515071b9 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -43,20 +43,13 @@ func GetVersion() string { return version } -// isRelease returns true if the current version is a release build -// (i.e. starts with "v", contains a dot, and is not dirty). -func isRelease() bool { - v := GetVersion() - return strings.HasPrefix(v, "v") && strings.Contains(v, ".") && !strings.Contains(v, "dirty") -} - // downloadAgentFileFromGitHub downloads the agentic-workflows.agent.md file from GitHub func downloadAgentFileFromGitHub(verbose bool) (string, error) { commandsLog.Print("Downloading agentic-workflows.agent.md from GitHub") // Determine the ref to use (tag for releases, main for dev builds) ref := "main" - if isRelease() { + if workflow.IsRelease() { ref = GetVersion() commandsLog.Printf("Using release tag: %s", ref) if verbose {