Add substring ID matching for all bd commands
- Enhanced ResolvePartialID to handle: - Bare hashes: 07b8c8 → bd-07b8c8 - Prefix without hyphen: bd07b8c8 → bd-07b8c8 - Full IDs: bd-07b8c8 (unchanged) - Substring matching: 07b → finds bd-07b8c8 - Added RPC support: - New OpResolveID operation - handleResolveID server handler - ResolveID client method - Updated all commands to resolve IDs: - show, update, close, reopen - dep (add, remove, tree) - label (add, remove, list) - Works in both daemon and direct modes Fixes bd-0591c3
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/utils"
|
||||
)
|
||||
|
||||
// normalizeLabels trims whitespace, removes empty strings, and deduplicates labels
|
||||
@@ -319,6 +320,31 @@ func (s *Server) handleList(req *Request) Response {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleResolveID(req *Request) Response {
|
||||
var args ResolveIDArgs
|
||||
if err := json.Unmarshal(req.Args, &args); err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("invalid resolve_id args: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
ctx := s.reqCtx(req)
|
||||
resolvedID, err := utils.ResolvePartialID(ctx, s.storage, args.ID)
|
||||
if err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("failed to resolve ID: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
data, _ := json.Marshal(resolvedID)
|
||||
return Response{
|
||||
Success: true,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleShow(req *Request) Response {
|
||||
var showArgs ShowArgs
|
||||
if err := json.Unmarshal(req.Args, &showArgs); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user