Skip to content

Support listing workflows from remote repositories#16423

Merged
pelikhan merged 9 commits intomainfrom
copilot/add-gh-aw-list-support
Feb 17, 2026
Merged

Support listing workflows from remote repositories#16423
pelikhan merged 9 commits intomainfrom
copilot/add-gh-aw-list-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

  • Understand current gh aw list command implementation
  • Add support for listing workflows from a remote repository
    • Add repo argument parsing (org/repo format)
    • Add function to fetch workflow files from remote repo via GitHub API
    • Handle authentication scenarios (with token, without token)
    • Update command to support both local and remote listing
  • Update command help text and examples
  • Add tests for remote repository listing
  • Test manually on github/gh-aw repository
  • Validate with formatting and tests
  • Change to use --repo flag instead of positional argument
  • Merge main and add CI validation
  • Add --path flag to support custom workflow directories
  • Merge main again and fix linting issues

Implementation Summary

Successfully implemented gh aw list --repo owner/repo functionality to list agentic workflows from different repositories, with support for custom workflow directory paths.

Key Features:

  • Supports both local and remote repository listing
  • GitHub API with git fallback for authentication issues
  • Optimized git clone using --filter=blob:none for fast listing
  • Remote repos show N/A for metadata (engine/compiled/labels) to avoid slow fetching
  • Pattern filtering works for both local and remote repos
  • --path flag allows specifying custom workflow directories (e.g., workflows/ instead of .github/workflows/)

CI Validation:

  • Added comparison test in integration-add job
  • Validates gh aw list --repo githubnext/agentics --path workflows matches shallow git clone results
  • Uses JSON output for reliable comparison
  • Reports differences in GitHub step summary

Syntax:

gh aw list                              # List local workflows
gh aw list --repo github/gh-aw          # List workflows from github/gh-aw
gh aw list --repo org/repo --path workflows  # List from custom path
gh aw list --repo github/gh-aw ci-      # Filter by pattern
gh aw list --repo github/gh-aw --json   # JSON output

Quality:

  • ✅ All linting checks pass
  • ✅ All unit tests pass
  • ✅ Code formatted correctly
  • ✅ Merged with latest main branch
Original prompt

The "gh aw list" command should support listing agentic workflows in a different repo

gh aw list org/repo

  • Test on itself.
  • handle cross org token issue, try without token too.

💡 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.

- Add `gh aw list owner/repo` syntax to list workflows from different repos
- Add ListWorkflowFiles function to parser package for fetching remote workflow lists
- Support both GitHub API and git fallback for listing files
- Use optimized git clone with --filter=blob:none for fast listing
- Remote repos show N/A for engine/compiled/labels to avoid slow metadata fetching
- Update command help text with examples
- Update tests to match new function signature

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot use flag --repo org/repo instead of adding nameless flag

Copilot AI changed the title [WIP] Add support for listing agentic workflows in different repo Support listing workflows from remote repositories Feb 17, 2026
Copilot AI requested a review from pelikhan February 17, 2026 18:56
Per feedback, changed from `gh aw list owner/repo` to `gh aw list --repo owner/repo` syntax.

- Use addRepoFlag() to add standard --repo/-r flag
- Pattern remains as optional positional argument
- Update help text and examples to show --repo flag usage
- All tests pass with new syntax

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot merge main and update ci.yml to compare list with files found by doing a shallow git clone in the integration_add job.

Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot use flag --repo org/repo instead of adding nameless flag

Changed to use --repo flag in commit 28e171e.

Updated syntax:

gh aw list --repo github/gh-aw      # List workflows from remote repo
gh aw list --repo github/gh-aw ci-  # With pattern filter

Help text showing --repo flag

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:

  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows
    • Triggering command: ./gh-aw ./gh-aw list --repo github/gh-aw smoke -c=4 -nolocalimports -importcfg /tmp/go-build109732835/b310/importcfg -pack /home/REDACTED/go/pkg/mod/golang.org/x/text@v0.34.0/internal/language/common.go /home/REDACTED/go/pkg/mod/golang.org/x/text@v0.34.0/internal/language/compact.go (http block)
    • Triggering command: ./gh-aw ./gh-aw list --repo github/gh-aw smoke (http block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login -D GOAMD64_v1 -gensymabis -o /tmp/go-build109732835/b147/symabis /opt/hostedtoolcache/go/1.25.0/x64/src/os/signal/sig.s (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login -c=4 -nolocalimports -importcfg /tmp/go-build109732835/b181/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/cli/shurcoo!l-graphql@v0.0.4/internal/jsonutil/graphql.go (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login -c=4 -nolocalimports -importcfg /tmp/go-build109732835/b284/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/goccy/go-yaml@v1.19.2/ast/ast.go (http block)

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

Copilot AI and others added 2 commits February 17, 2026 19:05
- Merged main branch to get latest CI changes
- Added comparison test in integration-add job
- Validates that 'gh aw list --repo githubnext/agentics' returns same workflows as shallow git clone
- Uses JSON output and jq to extract workflow names
- Compares sorted lists and reports differences if any
- Adds results to GitHub step summary with formatted output

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot merge main and update ci.yml to compare list with files found by doing a shallow git clone in the integration_add job.

Merged main and added CI validation in commit 2c9f3a6.

The integration-add job now includes a step that:

  • Runs gh aw list --repo githubnext/agentics --json
  • Extracts workflow names using jq
  • Compares them with the workflow files found by shallow git clone
  • Reports any differences in the GitHub step summary

The test will fail if the lists don't match, ensuring gh aw list accurately reflects repository contents.

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:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login -D GOAMD64_v1 -gensymabis -o /tmp/go-build919929483/b147/symabis /opt/hostedtoolcache/go/1.25.0/x64/src/os/signal/sig.s (http block)

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

@pelikhan pelikhan marked this pull request as ready for review February 17, 2026 19:21
Copilot AI review requested due to automatic review settings February 17, 2026 19:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for listing agentic workflows from remote GitHub repositories without requiring a local clone. The feature allows users to run gh aw list --repo owner/repo to list workflows from any repository.

Changes:

  • Added ListWorkflowFiles function in pkg/parser/remote_fetch.go that uses GitHub Contents API with git fallback for unauthenticated access
  • Updated gh aw list command to accept --repo flag and handle remote repository listing
  • Added CI validation to compare remote listing results with git clone results

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
pkg/parser/remote_fetch.go Implements ListWorkflowFiles and listWorkflowFilesViaGit for listing workflow files from remote repositories using GitHub API with git fallback
pkg/cli/list_workflows_command.go Adds --repo flag support, remote workflow listing logic, and helper functions (including unused extractMetadataFromRemoteFile)
pkg/cli/list_workflows_command_test.go Updates test function signatures to include new repo parameter
.github/workflows/ci.yml Adds validation step to compare gh aw list --repo output with git clone results
Comments suppressed due to low confidence (2)

pkg/cli/list_workflows_command.go:249

  • The repository parsing logic is duplicated here instead of reusing the existing parseRepoSpec function from pkg/cli/spec.go. The parseRepoSpec function already handles owner/repo[@ref] format and GitHub URLs with proper validation and error messages.

Consider refactoring to use parseRepoSpec for consistency across the codebase and to benefit from its better error handling and URL support.

	// Parse repo spec: owner/repo[@ref]
	var owner, repo, ref string
	parts := strings.SplitN(repoSpec, "@", 2)
	repoPart := parts[0]
	if len(parts) == 2 {
		ref = parts[1]
	} else {
		ref = "main" // default to main branch
	}

	// Parse owner/repo
	repoParts := strings.Split(repoPart, "/")
	if len(repoParts) != 2 {
		return nil, fmt.Errorf("invalid repository format: %s (expected owner/repo or owner/repo@ref)", repoSpec)
	}
	owner = repoParts[0]
	repo = repoParts[1]

pkg/cli/list_workflows_command.go:329

  • The function extractMetadataFromRemoteFile is defined but never used in the codebase. This appears to be dead code. Consider removing it if it's not part of a planned feature, or use it to properly extract metadata for remote repositories (which would fix the label filtering issue).
// extractMetadataFromRemoteFile fetches a remote workflow file and extracts engine ID, labels, and on field
func extractMetadataFromRemoteFile(repoSpec, filePath string, verbose bool, jsonOutput bool) (string, []string, any) {
	// Parse repo spec: owner/repo[@ref]
	var owner, repo, ref string
	parts := strings.SplitN(repoSpec, "@", 2)
	repoPart := parts[0]
	if len(parts) == 2 {
		ref = parts[1]
	} else {
		ref = "main"
	}

	// Parse owner/repo
	repoParts := strings.Split(repoPart, "/")
	if len(repoParts) != 2 {
		return "unknown", nil, nil
	}
	owner = repoParts[0]
	repo = repoParts[1]

	// Download file content (use optimized caching if available)
	content, err := parser.DownloadFileFromGitHub(owner, repo, filePath, ref)
	if err != nil {
		// If API fails, it may be falling back to git which is slow
		// For listing purposes, just return minimal info
		listWorkflowsLog.Printf("Skipping metadata fetch for %s (API unavailable, would require slow git fallback)", filePath)
		return "N/A", nil, nil
	}

	// Extract frontmatter
	result, err := parser.ExtractFrontmatterFromContent(string(content))
	if err != nil {
		listWorkflowsLog.Printf("Failed to extract frontmatter from %s: %v", filePath, err)
		return "unknown", nil, nil
	}

	// Extract engine ID
	engineID := "unknown"
	if result.Frontmatter != nil {
		if engine, ok := result.Frontmatter["engine"].(string); ok {
			engineID = engine
		}
	}

	// Extract labels
	var labels []string
	if result.Frontmatter != nil {
		if labelsField, ok := result.Frontmatter["labels"]; ok {
			if labelsArray, ok := labelsField.([]any); ok {
				for _, label := range labelsArray {
					if labelStr, ok := label.(string); ok {
						labels = append(labels, labelStr)
					}
				}
			}
		}
	}

	// Extract "on" field
	var onField any
	if result.Frontmatter != nil {
		onField = result.Frontmatter["on"]
	}

	return engineID, labels, onField
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +132 to +141
if isRemote {
// For remote repos, skip fetching individual file metadata to avoid slowness
// Just show file name with minimal info
workflows = append(workflows, WorkflowListItem{
Workflow: name,
EngineID: "N/A", // Skip fetching to avoid slow API/git calls
Compiled: "N/A", // Cannot determine for remote repos
Labels: nil,
On: nil,
})
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The label filter (--label flag) does not work for remote repositories. When isRemote is true, all workflows are added with Labels: nil and the label filtering check at line 183-194 is skipped. This means workflows from remote repositories will be shown even when they don't have the requested label.

Consider either:

  1. Documenting in the command help that --label filtering is not supported for remote repositories
  2. Checking the label filter early and returning an error if used with --repo
  3. Implementing label extraction for remote repositories (though this would require fetching each file)

This issue also appears on line 264 of the same file.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Contributor

@copilot update ci.yml list to list workflows in the workflows folder in gh-aw (add support in the command to select a subfolder)

See error

https://github.com/github/gh-aw/actions/runs/22111900614/job/63911613869#step:11:1

- Added --path flag (default: .github/workflows) to list command
- Updated ListWorkflowFiles to accept workflowPath parameter
- Updated CI to use --path workflows for githubnext/agentics repo
- Updated tests to include new path parameter
- Fixes CI failure where githubnext/agentics has workflows in workflows/ subfolder

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot update ci.yml list to list workflows in the workflows folder in gh-aw (add support in the command to select a subfolder)

...

Added --path flag in commit a486231.

The command now supports specifying a custom workflow directory:

gh aw list --repo githubnext/agentics --path workflows --json

Updated the CI to use --path workflows which resolves the error. The default path is .github/workflows for standard repositories.

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:

  • https://api.github.com/repos/githubnext/agentics/contents/workflows
    • Triggering command: ./gh-aw ./gh-aw list --repo githubnext/agentics --path workflows --json (http 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:

@pelikhan
Copy link
Contributor

@copilot merge main and lint go

Copilot AI and others added 2 commits February 17, 2026 20:39
- Merged latest changes from main branch
- Removed unused extractMetadataFromRemoteFile function
- All linting checks pass
- All unit tests pass

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot merge main and lint go

Merged main and fixed linting issues in commit c62bfcb.

Changes:

  • Merged latest commits from main branch
  • Removed unused extractMetadataFromRemoteFile function
  • All linting checks pass (make lint)
  • All unit tests pass

@pelikhan pelikhan merged commit 8695686 into main Feb 17, 2026
89 of 90 checks passed
@pelikhan pelikhan deleted the copilot/add-gh-aw-list-support branch February 17, 2026 21:24
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