feat(completion): optimize ID prefix filtering and add completions to more commands

Improvements to shell completions from PR #935:

1. Add IDPrefix field to IssueFilter for efficient database-level filtering
   - Queries are now filtered at SQL level instead of fetching all issues
   - Updated sqlite, transaction, and memory stores to support IDPrefix

2. Add ValidArgsFunction to additional commands:
   - dep (add, remove, list, tree)
   - comments, comment (add)
   - delete
   - graph
   - label (add, remove, list)
   - duplicate, supersede
   - audit
   - move
   - relate, unrelate
   - refile
   - gate (show, resolve, add-waiter)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/dave
Rig: beads
Role: crew
This commit is contained in:
beads/crew/dave
2026-01-06 19:05:34 -08:00
committed by Steve Yegge
parent 025cdac962
commit 5dfb838d60
16 changed files with 59 additions and 11 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"path/filepath"
"strings"
"time"
"github.com/spf13/cobra"
@@ -51,8 +50,10 @@ func issueIDCompletion(cmd *cobra.Command, args []string, toComplete string) ([]
defer currentStore.Close()
}
// Use SearchIssues with empty query and default filter to get all issues
filter := types.IssueFilter{}
// Use SearchIssues with IDPrefix filter to efficiently query matching issues
filter := types.IssueFilter{
IDPrefix: toComplete, // Filter at database level for better performance
}
issues, err := currentStore.SearchIssues(ctx, "", filter)
if err != nil {
// If we can't list issues, return empty completion
@@ -62,11 +63,6 @@ func issueIDCompletion(cmd *cobra.Command, args []string, toComplete string) ([]
// Build completion list
completions := make([]string, 0, len(issues))
for _, issue := range issues {
// Filter based on what's already typed
if toComplete != "" && !strings.HasPrefix(issue.ID, toComplete) {
continue
}
// Format: ID\tTitle (shown during completion)
completions = append(completions, fmt.Sprintf("%s\t%s", issue.ID, issue.Title))
}