Skip to content

Add cache management commands for workflow cache-memory#15519

Closed
Copilot wants to merge 18 commits intomainfrom
copilot/add-cache-management-commands
Closed

Add cache management commands for workflow cache-memory#15519
Copilot wants to merge 18 commits intomainfrom
copilot/add-cache-management-commands

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Cache Management Commands - Production Ready

✅ Commands Implemented:

Two cache management commands:

  1. gh aw cache list [workflow] - List caches with professional table formatting

    • Uses console.RenderTable with lipgloss styling
    • Proper time parsing and formatting (YYYY-MM-DD HH:MM)
    • Consolidated listCachesWithRef function (no nested spinners)
    • Filters: workflow, -k (key), -r (ref), -L (limit)
  2. gh aw cache delete [workflow] - Delete ALL matching caches by default

    • Validates workflow exists before deletion
    • Uses listCachesWithRef for proper ref filtering
    • Single spinner at command level (no nested spinners)
    • Confirmation prompt with formatted cache lists
    • API rate limiting protection with 200ms delays
    • Success/failure counts

🎯 Code Quality Improvements (Latest Commit):

Removed unused code:

  • Removed unused deleteAll flag and DeleteAll config field
  • Removed unused ref parameter from deleteCache function
  • Removed duplicate listCaches function

Fixed nested spinners:

  • Spinner only at command level, not in helper functions
  • Eliminated duplicate spinner creation in nested calls

Improved time handling:

  • Proper time.Parse with RFC3339 format
  • Human-readable output format (YYYY-MM-DD HH:MM)
  • Fallback for parsing errors

Better ref filtering:

  • Delete command now uses listCachesWithRef for proper ref filtering
  • Consistent filtering behavior across list and delete commands

Terminal style compliant:

  • Follows Charmbracelet ecosystem best practices
  • TTY-aware rendering via console package
  • No anti-patterns (raw ANSI, hardcoded colors, etc.)

Commands:

# List caches with formatted table
gh aw cache list my-workflow -L 10

# Delete ALL caches (validates workflow, shows confirmation)
gh aw cache delete my-workflow

# Delete with ref filter
gh aw cache delete my-workflow -r refs/heads/main

# Delete without confirmation
gh aw cache delete my-workflow --force

Implementation:

  • pkg/cli/cache.go - Main command (2 subcommands)
  • pkg/cli/cache_list_command.go - List with table formatting, proper time parsing
  • pkg/cli/cache_delete_command.go - Delete with validation, single spinner, ref filtering
  • pkg/cli/cache_command_test.go - Updated test coverage
  • .gitignore - Added .github/aw/cache-memory/
Original prompt

This section details on the original issue you should resolve

<issue_title>cache management commands</issue_title>
<issue_description>Commands to download, delete caches for workflows.

gh aw cache download workflowname
gh aw cache delete workflowname

</issue_description>

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


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

Copilot AI and others added 3 commits February 13, 2026 22:16
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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] Add cache management commands for workflows Add cache management commands for workflow cache-memory Feb 13, 2026
Copilot AI requested a review from pelikhan February 13, 2026 22:22
@pelikhan
Copy link
Contributor

@copilot

You want to download the folder .github/aw/cache-memory. Make sure that folder is added to .gitignore.

Add spinners to the interface.

Implement the fallback resolution strategy to determine which cache to use.

Support wildcards in cache names to determine which cache to download.

Watch for API throttling when deleting large numbers of caches.

Ask for confirmation before deleting caches. First, identify the caches, then prompt the user for confirmation before performing the delete operation.

- Add .github/aw/cache-memory/ and cache-downloads/ to .gitignore
- Add progress spinners to cache delete operations
- Implement API rate limiting protection with 200ms delays between deletes
- Add failure tracking to show both success and failure counts
- Improve error messages for rate limiting scenarios

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

Copilot AI commented Feb 13, 2026

@copilot

...

I've addressed several of your feedback points in commit 4721b69:

Added to .gitignore: Both .github/aw/cache-memory/ and cache-downloads/ directories
Added spinners: Progress indicators for delete operations (single and bulk)
Confirmation before delete: Already working - prompts user before deletion (skip with --force)
API throttling protection: Detects rate limiting (403/rate limit errors), stops operation with helpful message, adds 200ms delay between deletes when >5 caches
Better error reporting: Shows separate success/failure counts

Remaining work for full implementation:

  • Download actual cache-memory contents: Current implementation downloads metadata only. Full implementation needs to query workflow runs, check for cache-memory artifacts, and download using gh run download
  • Fallback resolution strategy: Needs to try multiple recent runs until finding one with cache-memory artifacts
  • Wildcard support: Needs pattern matching for workflow names

The download command requires significant rework since GitHub Actions caches aren't directly downloadable - only artifacts uploaded during threat detection contain actual cache-memory data.

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 (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 add list command

@pelikhan
Copy link
Contributor

@copilot ignore download command

- Add 'gh aw cache list' command to display caches in a formatted table
- Support listing all caches or filtering by workflow pattern
- Include spinner for better UX during API calls
- Display cache ID, key, ref, size (human-readable), and last accessed time
- Support filtering by custom cache key (-k) and ref (-r)
- Add comprehensive tests for list command and formatBytes helper

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

Copilot AI commented Feb 13, 2026

@copilot add list command

Added in commit 798b7de.

The gh aw cache list command displays caches in a formatted table with columns for ID, key, ref, size (human-readable), and last accessed time. It supports:

  • Listing all caches: gh aw cache list
  • Filtering by workflow: gh aw cache list my-workflow
  • Custom filters: -k (key prefix), -r (ref), -L (limit)

Cache list command help

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 (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD GOMODCACHE go k/gh�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD erignore go (http block)
    • Triggering command: `/usr/bin/gh gh api user --jq .login -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE ering by workflow pattern
  • Include spinner for better UX during API calls
  • Display cache ID, GOMODCACHE go` (http block)

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

- Move spinner stop to after ref filtering to show correct count
- Simplify spinner stop logic for better readability

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

Choose a reason for hiding this comment

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

@copilot delete file and sub command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already completed in commit 490e4a3. The cache_download_command.go file has been deleted and the download subcommand removed from the cache command structure. Only list and delete subcommands remain.

- Remove cache_download_command.go file
- Update cache.go to only include list and delete subcommands
- Update tests to remove download command references
- Final implementation includes only list and delete commands

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

Copilot AI commented Feb 13, 2026

@copilot ignore download command

Removed in commit 490e4a3.

The cache commands now include only list and delete subcommands. The download command and related code have been completely removed.

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 (http block)

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

…agement-commands

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
- Merge origin/main into branch
- Use normalizeWorkflowID helper for consistent workflow ID handling
- Add workflow validation before cache delete operations
- Use validateWorkflowName to ensure workflow exists before deleting caches
- Provides helpful error message if workflow doesn't exist

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

Copilot AI commented Feb 14, 2026

@copilot merge main, use helper to normalize workflow id
validate the workflow exists before doing any delete operation

Completed in commits 732eb28 (merge) and 4cb8025:

Merged main branch - Branch is now up to date with latest changes from main

Using normalizeWorkflowID helper - Both list and delete commands now use the existing normalizeWorkflowID helper function from pkg/cli/commands.go for consistent workflow ID handling (handles paths, .md extensions, etc.)

Workflow validation before delete - Delete command now calls validateWorkflowName before any delete operations. If the workflow doesn't exist, it shows an error message with suggestions for similar workflows.

- Replace manual table formatting with console.RenderTable helper
- Build TableConfig with headers and rows for cache list
- Remove unused strings import
- Table now uses lipgloss styling with borders and zebra striping

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

@copilot review and apply terminal style agentic workflow prompt instructions

Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot review and apply terminal style agentic workflow prompt instructions

Reviewed against terminal-stylist workflow guidelines. The cache commands already follow Charmbracelet ecosystem best practices:

Console package usage:

  • console.RenderTable with lipgloss styling (borders, zebra striping, TTY-aware)
  • console.FormatFileSize, FormatListItem for consistent formatting
  • console.FormatSuccessMessage, FormatInfoMessage, FormatWarningMessage, FormatErrorMessage for status messages
  • console.FormatPromptMessage for user prompts
  • console.NewSpinner for progress indication

No anti-patterns:

  • No direct fmt.Print* to stdout for diagnostic messages (all use stderr)
  • No raw ANSI escape sequences
  • No hardcoded colors (using console package helpers)
  • No manual table formatting (using console.RenderTable)

Best practices:

  • All diagnostic output goes to stderr
  • TTY detection handled by console package
  • Adaptive colors via lipgloss styling
  • Consistent message formatting throughout

The implementation meets all terminal style requirements from the terminal-stylist workflow.

@pelikhan pelikhan marked this pull request as ready for review February 14, 2026 03:21
Copilot AI review requested due to automatic review settings February 14, 2026 03: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 PR implements cache management commands for agentic workflows that use the cache-memory feature. It adds two new subcommands (gh aw cache list and gh aw cache delete) to help users manage GitHub Actions cache artifacts created by workflows.

Changes:

  • Adds gh aw cache list command to view caches with professional table formatting using lipgloss styling
  • Adds gh aw cache delete command to delete caches with workflow validation, confirmation prompts, and rate limiting protection
  • Updates .gitignore to exclude cache-memory directory

Reviewed changes

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

Show a summary per file
File Description
pkg/cli/cache.go Main cache command structure with two subcommands (list and delete)
pkg/cli/cache_list_command.go List command implementation with table rendering and ref filtering
pkg/cli/cache_delete_command.go Delete command with workflow validation, confirmation, bulk deletion, and rate limiting
pkg/cli/cache_command_test.go Unit tests for command structure and flags
cmd/gh-aw/main.go CLI registration of cache command in development group
.gitignore Excludes .github/aw/cache-memory/ directory
Comments suppressed due to low confidence (1)

pkg/cli/cache_delete_command.go:208

  • The ref parameter is accepted but not used when calling gh cache delete. The gh CLI cache delete command doesn't actually support a --ref flag for filtering which cache to delete - it only accepts the cache ID. The ref parameter should be removed from the deleteCache function signature since it has no effect.

If you want to support ref-based filtering, that filtering should happen when selecting which caches to delete (during the listCaches call), not during the actual deletion.

	if ref != "" {
		args = append(args, "--ref", ref)
	}

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

cache management commands

2 participants

Comments