Skip to content

Add workflow descriptions to shell completions#8565

Merged
pelikhan merged 2 commits intomainfrom
copilot/add-completion-descriptions
Jan 2, 2026
Merged

Add workflow descriptions to shell completions#8565
pelikhan merged 2 commits intomainfrom
copilot/add-completion-descriptions

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

Shell completions now display workflow descriptions alongside names when users press TAB, leveraging Cobra's tab-separated completion format.

Changes

  • Added getWorkflowDescription() - Extracts description field from workflow frontmatter with fallback to name field. Truncates at 60 characters.

  • Updated CompleteWorkflowNames() - Returns "workflow-name\tdescription" format for shells to parse (bash/zsh/fish compatible).

  • Added tests - Coverage for description extraction, truncation, fallback behavior, and prefix filtering.

Example Output

$ gh aw compile <TAB>
audit-workflows     Daily audit of all agentic workflow runs from the last 24...
ci-coach           Daily CI optimization coach that analyzes workflow runs f...
ci-doctor          Investigates failed CI workflows to identify root causes ...

Workflows without descriptions display name only (graceful degradation).

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Add completion descriptions for workflow names using CompletionWithDesc</issue_title>
<issue_description>## Objective

Enhance shell completions to show workflow descriptions alongside workflow names when users press TAB, leveraging Cobra v1.9.0+ CompletionWithDesc functionality.

Context

Currently, shell completions only show workflow names. With completion descriptions, users will see:

my-workflow        Daily CI workflow for testing
deploy-prod        Production deployment workflow

This significantly improves discoverability and reduces need to check workflow files.

Implementation Approach

  1. Locate completion function in pkg/cli/completions.go:

    • Find CompleteWorkflowNames() function
  2. Create description extractor:

    func getWorkflowDescription(filepath string) string {
        // Read markdown file
        // Parse frontmatter
        // Extract 'description' or 'name' field
        // Return truncated string (max 60 chars)
    }
  3. Update completion function to use tab-separated format:

    for _, file := range mdFiles {
        name := strings.TrimSuffix(filepath.Base(file), ".md")
        desc := getWorkflowDescription(file)
        completions = append(completions, fmt.Sprintf("%s\t%s", name, desc))
    }
  4. Test in multiple shells:

    • Bash: gh aw run (TAB)
    • Zsh: gh aw compile (TAB)
    • Fish: gh aw enable (TAB)

Files to Modify

  • Update: pkg/cli/completions.go

    • Modify CompleteWorkflowNames() to include descriptions
    • Add getWorkflowDescription() helper function
  • Update: pkg/cli/completions_test.go (if exists, otherwise create)

    • Add tests for description extraction
    • Test truncation behavior

Acceptance Criteria

  • Shell completions show workflow descriptions in bash/zsh/fish
  • Descriptions are truncated to reasonable length (60 chars)
  • Fallback to empty string if description not available
  • No performance degradation (descriptions cached if needed)
  • Test coverage for new functionality

References

AI generated by Plan Command for discussion #8545

Comments on the Issue (you are @copilot in this section)


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

- Add getWorkflowDescription() helper to extract descriptions from frontmatter
- Update CompleteWorkflowNames() to return tab-separated format
- Support description field with fallback to name field
- Truncate descriptions to 60 characters for readability
- Add comprehensive tests for description extraction and completion
- All tests passing and binary builds successfully

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add completion descriptions for workflow names Add workflow descriptions to shell completions Jan 2, 2026
Copilot AI requested a review from mnkiefer January 2, 2026 05:14
@pelikhan pelikhan marked this pull request as ready for review January 2, 2026 05:19
@pelikhan pelikhan merged commit 4d3d571 into main Jan 2, 2026
209 checks passed
@pelikhan pelikhan deleted the copilot/add-completion-descriptions branch January 2, 2026 05:20
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.

[plan] Add completion descriptions for workflow names using CompletionWithDesc

3 participants