Support listing workflows from remote repositories#16423
Conversation
- 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>
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>
|
@copilot merge main and update ci.yml to compare list with files found by doing a shallow git clone in the integration_add job. |
Changed to use Updated syntax: gh aw list --repo github/gh-aw # List workflows from remote repo
gh aw list --repo github/gh-aw ci- # With pattern filterWarning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
- 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>
Merged main and added CI validation in commit 2c9f3a6. The
The test will fail if the lists don't match, ensuring 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
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
ListWorkflowFilesfunction inpkg/parser/remote_fetch.gothat uses GitHub Contents API with git fallback for unauthenticated access - Updated
gh aw listcommand to accept--repoflag 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
parseRepoSpecfunction frompkg/cli/spec.go. TheparseRepoSpecfunction already handlesowner/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
extractMetadataFromRemoteFileis 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.
| 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, | ||
| }) |
There was a problem hiding this comment.
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:
- Documenting in the command help that
--labelfiltering is not supported for remote repositories - Checking the label filter early and returning an error if used with
--repo - 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 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>
Added --path flag in commit a486231. The command now supports specifying a custom workflow directory: gh aw list --repo githubnext/agentics --path workflows --jsonUpdated the CI to use 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot merge main and lint go |
- 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>

gh aw listcommand implementationImplementation Summary
Successfully implemented
gh aw list --repo owner/repofunctionality to list agentic workflows from different repositories, with support for custom workflow directory paths.Key Features:
--filter=blob:nonefor fast listing--pathflag allows specifying custom workflow directories (e.g.,workflows/instead of.github/workflows/)CI Validation:
integration-addjobgh aw list --repo githubnext/agentics --path workflowsmatches shallow git clone resultsSyntax:
Quality:
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.