diff --git a/cmd/bd/create.go b/cmd/bd/create.go index f7bb8cd0..41228b6b 100644 --- a/cmd/bd/create.go +++ b/cmd/bd/create.go @@ -738,8 +738,8 @@ func createInRig(cmd *cobra.Command, rigName, title, description, issueType stri FatalError("cannot use --rig: %v", err) } - // Resolve the target rig's beads directory - targetBeadsDir, _, err := routing.ResolveBeadsDirForRig(rigName, townBeadsDir) + // Resolve the target rig's beads directory and prefix + targetBeadsDir, targetPrefix, err := routing.ResolveBeadsDirForRig(rigName, townBeadsDir) if err != nil { FatalError("%v", err) } @@ -756,6 +756,13 @@ func createInRig(cmd *cobra.Command, rigName, title, description, issueType stri } }() + // Prepare prefix override from routes.jsonl for cross-rig creation + // Strip trailing hyphen - database stores prefix without it (e.g., "aops" not "aops-") + var prefixOverride string + if targetPrefix != "" { + prefixOverride = strings.TrimSuffix(targetPrefix, "-") + } + var externalRefPtr *string if externalRef != "" { externalRefPtr = &externalRef @@ -824,6 +831,8 @@ func createInRig(cmd *cobra.Command, rigName, title, description, issueType stri // Time scheduling fields (bd-xwvo fix) DueAt: dueAt, DeferUntil: deferUntil, + // Cross-rig routing: use route prefix instead of database config + PrefixOverride: prefixOverride, } if err := targetStore.CreateIssue(ctx, issue, actor); err != nil { diff --git a/internal/storage/sqlite/queries.go b/internal/storage/sqlite/queries.go index ba913dff..0dda0082 100644 --- a/internal/storage/sqlite/queries.go +++ b/internal/storage/sqlite/queries.go @@ -167,10 +167,14 @@ func (s *SQLiteStorage) CreateIssue(ctx context.Context, issue *types.Issue, act return fmt.Errorf("failed to get config: %w", err) } - // Use IDPrefix override if set, combined with config prefix - // e.g., configPrefix="bd" + IDPrefix="wisp" → "bd-wisp" + // Determine prefix for ID generation and validation: + // 1. PrefixOverride completely replaces config prefix (for cross-rig creation) + // 2. IDPrefix appends to config prefix (e.g., "bd" + "wisp" → "bd-wisp") + // 3. Otherwise use config prefix as-is prefix := configPrefix - if issue.IDPrefix != "" { + if issue.PrefixOverride != "" { + prefix = issue.PrefixOverride + } else if issue.IDPrefix != "" { prefix = configPrefix + "-" + issue.IDPrefix } diff --git a/internal/types/types.go b/internal/types/types.go index cb1ffd33..8e8b8e9c 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -56,8 +56,9 @@ type Issue struct { OriginalSize int `json:"original_size,omitempty"` // ===== Internal Routing (not exported to JSONL) ===== - SourceRepo string `json:"-"` // Which repo owns this issue (multi-repo support) - IDPrefix string `json:"-"` // Override prefix for ID generation + SourceRepo string `json:"-"` // Which repo owns this issue (multi-repo support) + IDPrefix string `json:"-"` // Override prefix for ID generation (appends to config prefix) + PrefixOverride string `json:"-"` // Completely replace config prefix (for cross-rig creation) // ===== Relational Data (populated for export/import) ===== Labels []string `json:"labels,omitempty"`