Implement prefix-optional ID parsing (bd-170)

- Add internal/utils/id_parser.go with ParseIssueID and ResolvePartialID
- Update all CLI commands to accept IDs without prefix (e.g., '170' or 'bd-170')
- Add comprehensive tests for ID parsing functionality
- Works in direct mode; RPC handlers to be updated in bd-177

Commands updated:
- show, update, edit, close (show.go)
- reopen (reopen.go)
- dep add/remove/tree (dep.go)
- label add/remove/list (label.go)
- comments (comments.go)

Amp-Thread-ID: https://ampcode.com/threads/T-1f6a301b-b53f-440f-bd79-e453234ac1c9
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-30 15:41:46 -07:00
parent 9876d825a6
commit 2eb4c883ab
7 changed files with 503 additions and 33 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/rpc"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/utils"
)
var commentsCmd = &cobra.Command{
@@ -63,6 +64,13 @@ Examples:
os.Exit(1)
}
ctx := context.Background()
fullID, err := utils.ResolvePartialID(ctx, store, issueID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error resolving %s: %v\n", issueID, err)
os.Exit(1)
}
issueID = fullID
result, err := store.GetIssueComments(ctx, issueID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting comments: %v\n", err)
@@ -176,7 +184,14 @@ Examples:
os.Exit(1)
}
ctx := context.Background()
var err error
fullID, err := utils.ResolvePartialID(ctx, store, issueID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error resolving %s: %v\n", issueID, err)
os.Exit(1)
}
issueID = fullID
comment, err = store.AddIssueComment(ctx, issueID, author, commentText)
if err != nil {
fmt.Fprintf(os.Stderr, "Error adding comment: %v\n", err)