Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

gh aw add owner/repo previously returned a cryptic error with no workflow discovery mechanism. Now installs the package and lists available workflows with usage examples.

Changes

Detection & Routing

  • Added isRepoOnlySpec() to detect 2-part specs (owner/repo[@version])
  • Modified AddWorkflows() to route repo-only specs to new handler
  • Excludes URLs, local paths, and full workflow specs

Workflow Enumeration

  • Added listWorkflowsInPackage() to walk package directory and enumerate .md files
  • Returns relative paths from package root

User Output

  • Added handleRepoOnlySpec() to orchestrate: install package → list workflows → format output
  • Shows bullet list of workflows with example add command

Help Text

  • Updated command documentation to include 2-part specification format

Example

$ gh aw add githubnext/agentics

Installing repository githubnext/agentics...
Successfully installed package: githubnext/agentics

ℹ Please specify which workflow you want to add from githubnext/agentics:

  • ci-doctor
  • daily-plan
  • issue-labeler

Example:
  gh aw add githubnext/agentics/ci-doctor

All existing 3+ part specs unchanged. Backward compatible.

Original prompt

Update the "add" command such that when the user provider only the repo name, it responds with the list of workflows available to add from that repostiory.

NOW:

@pelikhan ➜ /workspaces/gh-aw (main) $ ./gh-aw add githubnext/agentics
✗ invalid workflow specification 'githubnext/agentics': workflow specificationwor must be in format 'owner/repo/workflow-name[@version]'

BETTER:

@pelikhan ➜ /workspaces/gh-aw (main) $ ./gh-aw add githubnext/agentics

Please specify which  workflow you want to add from githubnext/agentics:
   - workflow1
  - workflow2 
 ...

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 6, 2025 18:17
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] Update add command to list available workflows List workflows when only repo name provided to add command Nov 6, 2025
Copilot AI requested a review from pelikhan November 6, 2025 18:24
Copilot finished work on behalf of pelikhan November 6, 2025 18:24
@pelikhan pelikhan marked this pull request as ready for review November 6, 2025 19:22
Copilot AI review requested due to automatic review settings November 6, 2025 19:22
@pelikhan pelikhan merged commit 7a3e6af into main Nov 6, 2025
73 of 78 checks passed
@pelikhan pelikhan deleted the copilot/update-add-command-workflow-list branch November 6, 2025 19:23
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 PR adds support for listing available workflows when a user provides only a repository specification (e.g., owner/repo) without specifying a particular workflow. When this occurs, the system installs the repository package and displays all available workflows to help users discover what's available.

Key changes:

  • Adds isRepoOnlySpec() function to detect when only a repository (not a specific workflow) is provided
  • Implements listWorkflowsInPackage() to scan and list all workflow files in an installed package
  • Introduces handleRepoOnlySpec() to manage the repo-only flow (install package, list workflows, display examples)

Reviewed Changes

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

File Description
pkg/cli/spec.go Adds isRepoOnlySpec() function to identify repository-only specifications
pkg/cli/packages.go Implements listWorkflowsInPackage() to enumerate workflow files in installed packages
pkg/cli/add_repo_only_test.go Adds unit tests for the new repo-only specification handling functionality
pkg/cli/add_command.go Updates command help text and integrates repo-only spec detection into the add workflow flow

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

Comment on lines +275 to +279
// Skip metadata files
if info.Name() == ".commit-sha" {
return nil
}

Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

This condition is checking a filename against a file that should be .commit-sha, but the previous check already filters out directories and only processes .md files (line 271). Since .commit-sha doesn't end with .md, this check is unreachable and unnecessary.

Suggested change
// Skip metadata files
if info.Name() == ".commit-sha" {
return nil
}

Copilot uses AI. Check for mistakes.
Comment on lines +286 to +293
// Extract workflow name (remove .md extension)
workflowName := strings.TrimSuffix(filepath.Base(path), ".md")

// Add to list with relative path information
workflows = append(workflows, relPath)

if verbose {
fmt.Printf("Found workflow: %s (name: %s)\n", relPath, workflowName)
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

The variable workflowName is computed but never used in a meaningful way. It's only printed in verbose mode (line 293) but doesn't contribute to the function's output. Consider removing this variable or documenting why it's kept for debugging purposes only.

Suggested change
// Extract workflow name (remove .md extension)
workflowName := strings.TrimSuffix(filepath.Base(path), ".md")
// Add to list with relative path information
workflows = append(workflows, relPath)
if verbose {
fmt.Printf("Found workflow: %s (name: %s)\n", relPath, workflowName)
// Add to list with relative path information
workflows = append(workflows, relPath)
if verbose {
fmt.Printf("Found workflow: %s\n", relPath)

Copilot uses AI. Check for mistakes.
}

fmt.Fprintln(os.Stderr, "")
fmt.Fprintf(os.Stderr, "Example:\n")
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

[nitpick] The label should be plural 'Examples:' to match the pattern used elsewhere in the codebase (see line 28), or keep it singular but add a colon for consistency.

Suggested change
fmt.Fprintf(os.Stderr, "Example:\n")
fmt.Fprintf(os.Stderr, "Examples:\n")

Copilot uses AI. Check for mistakes.
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