-
Notifications
You must be signed in to change notification settings - Fork 28
Show available workflows when workflow not found in add command #3402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this 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 enhances the add command's error handling by displaying available workflows from an installed package when a specific workflow is not found, providing more helpful guidance to users.
Key Changes:
- Added
displayAvailableWorkflows()function that lists workflows from installed packages with examples - Modified error handling in
addWorkflowWithTracking()to call the new function before falling back to generic help - Added comprehensive test coverage for the new functionality including edge cases (no workflows, package not found, with/without version)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pkg/cli/add_workflow_not_found_test.go | New test file with 4 test cases covering workflow listing scenarios: basic display, version handling, empty package, and missing package |
| pkg/cli/add_command.go | Added displayAvailableWorkflows() function and integrated it into workflow-not-found error flow to provide contextual help instead of generic instructions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Extract workflow name from path (remove .md extension and path) | ||
| workflowName := strings.TrimSuffix(filepath.Base(workflow), ".md") | ||
|
|
||
| // For workflows in workflows/ directory, show simplified name | ||
| if strings.HasPrefix(workflow, "workflows/") { | ||
| workflowName = strings.TrimSuffix(strings.TrimPrefix(workflow, "workflows/"), ".md") | ||
| } |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated workflow name extraction logic: The logic for extracting workflow names from paths (lines 320-326) is duplicated almost identically in lines 344-348 for the example workflow. Consider extracting this into a small helper function to avoid code duplication and make the logic easier to maintain.
| w.Close() | ||
| os.Stderr = oldStderr | ||
| var buf bytes.Buffer | ||
| buf.ReadFrom(r) |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error check: The return value from buf.ReadFrom(r) is not checked. While this is unlikely to fail in tests, it's best practice to check errors, especially since other I/O operations in the same tests do check errors.
| buf.ReadFrom(r) | |
| if _, err := buf.ReadFrom(r); err != nil { | |
| t.Fatalf("Failed to read from pipe: %v", err) | |
| } |
| w.Close() | ||
| os.Stderr = oldStderr | ||
| var buf bytes.Buffer | ||
| buf.ReadFrom(r) |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error check: The return value from buf.ReadFrom(r) is not checked. While this is unlikely to fail in tests, it's best practice to check errors, especially since other I/O operations in the same tests do check errors.
| buf.ReadFrom(r) | |
| if _, err := buf.ReadFrom(r); err != nil { | |
| t.Fatalf("Failed to read from pipe: %v", err) | |
| } |
Update documentation to reflect recent feature changes and improvements. Changes made: - Remove outdated bash wildcard restriction in strict mode (PR #3407) - Update CLI documentation for improved workflow discovery (PR #3402, #3406) - Document wildcard workflow addition with better error handling (PR #3404) - Update security guide to use neutral language about wildcards Referenced PRs: - #3407 - Remove bash wildcard restriction in strict mode - #3406 - Display workflow list as table with ID, Name, and Description - #3402 - Show available workflows when workflow not found in add command - #3404 - Emit warning instead of error when wildcard adds encounter existing workflows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update documentation to reflect recent feature changes and improvements. Changes made: - Remove outdated bash wildcard restriction in strict mode (PR #3407) - Update CLI documentation for improved workflow discovery (PR #3402, #3406) - Document wildcard workflow addition with better error handling (PR #3404) - Update security guide to use neutral language about wildcards Referenced PRs: - #3407 - Remove bash wildcard restriction in strict mode - #3406 - Display workflow list as table with ID, Name, and Description - #3402 - Show available workflows when workflow not found in add command - #3404 - Emit warning instead of error when wildcard adds encounter existing workflows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
When
gh aw add owner/repo/workflow-namefails because the workflow doesn't exist, users get generic help text with no indication of what workflows are actually available in the installed package.Changes
displayAvailableWorkflows(): Lists all workflows from the installed package with example commandsaddWorkflowWithTracking(): CallsdisplayAvailableWorkflows()when workflow not found, falls back to generic help on failureExample
Before:
After:
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.