* fix(workspace): align resolved workspace messaging and config lookup intent(workspace): pure worktrees and external BEADS_DIR setups should work without implying a local .beads directory is required decision(config): derive config repo roots from FindBeadsDir-backed workspace resolution instead of a local-only .beads walk constraint(workspace-detection): keep FindBeadsDir ordering and storage behavior unchanged while making bd where the primary diagnostic hint learned(testing): shared-server env and global .beads ignore rules can distort CGO suites, so regression coverage now normalizes those test paths * fix(bootstrap): align no-workspace JSON wording intent(bootstrap): machine-readable no-workspace output should match the resolved-workspace guidance used elsewhere on this branch decision(bootstrap-json): reuse the shared workspace error helpers through a dedicated payload builder so tests can lock the JSON contract constraint(review-loop): keep the bootstrap CLI flow unchanged outside the no-workspace JSON branch while adding a focused regression test * fix(where): allow no-workspace diagnostics without db (beads-9f74-5l1) intent(where): no-workspace guidance should point to a command that actually runs when workspace resolution fails decision(startup): treat top-level where as a no-db command so it reaches its own handler before database preflight constraint(where-tests): subprocess mode can change the exact hint text, so the regression test locks the JSON contract and stable guidance fragments instead * fix(bootstrap): restore bd where guidance for no-workspace output (beads-9f74-3c3) intent(bootstrap): no-workspace bootstrap guidance should match the resolved-workspace diagnostics introduced on this branch decision(no-workspace-hints): reuse the shared hint that mentions bd where instead of the bootstrap-specific fallback text constraint(bootstrap-tests): cover both the payload helper and subprocess CLI path so wording regressions are caught before release * fix(workspace): remove no-workspace .beads fallbacks (beads-9f74-gr1) intent(workspace-resolution): finish the GH#3124 follow-up for runtime paths that still fabricated local .beads state rejected(no-workspace-fallback): inventing ./ .beads paths outside an active workspace hid shared-worktree resolution and created stray files decision(setup-recipes): keep built-in bd setup recipes usable without a workspace but require an active workspace for custom recipe state constraint(worktree-support): completion and backup helpers still need to resolve shared main-repo workspaces from a git worktree * fix(config): skip no-workspace store init for store-free commands intent(config): review-fix-loop found no-workspace config commands should reach their own graceful paths instead of failing in PersistentPreRun decision(config-preflight): detect store-free config subcommands before DB synthesis so config.yaml, git-backed, and diagnostic flows can run without an opened store constraint(json-contract): keep bd config validate --json machine-readable on stdout once pre-run stops short-circuiting into low-level DB errors learned(config-preflight): the parent config command not being in noDbCommands leaked store init into show, validate, drift, apply, and yaml-only config helpers * fix(ci): restore init prefix normalization and formatting intent(ci): clear the current PR failures instead of leaving the branch blocked behind known red checks decision(init-prefix): normalize dotted prefixes before persisting issue_prefix so config, metadata.json, and Dolt database naming stay aligned for Julia-style repos constraint(fmt-check): CI runs gofmt over the whole repo, so the existing spacing drift in internal/jira/tracker_test.go had to be cleaned up on this branch to get a green run learned(ci): the latest main CI was already red on the same formatting file and the same embedded shard, so rebasing surfaced pre-existing blockers rather than introducing a new shard-only regression
60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/beads"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// issueIDCompletion provides shell completion for issue IDs by querying the storage
|
|
// and returning a list of IDs with their titles as descriptions
|
|
func issueIDCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
// Initialize storage if not already initialized
|
|
ctx := context.Background()
|
|
if rootCtx != nil {
|
|
ctx = rootCtx
|
|
}
|
|
|
|
// Get database path - use same logic as in PersistentPreRun
|
|
currentDBPath := dbPath
|
|
if currentDBPath == "" {
|
|
currentDBPath = beads.FindDatabasePath()
|
|
if currentDBPath == "" {
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
}
|
|
}
|
|
|
|
// Open database if store is not initialized
|
|
currentStore := store
|
|
if currentStore == nil {
|
|
var err error
|
|
currentStore, err = openReadOnlyStoreForDBPath(ctx, currentDBPath)
|
|
if err != nil {
|
|
// If we can't open database, return empty completion
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
}
|
|
defer func() { _ = currentStore.Close() }()
|
|
}
|
|
|
|
// 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
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
}
|
|
|
|
// Build completion list
|
|
completions := make([]string, 0, len(issues))
|
|
for _, issue := range issues {
|
|
// Format: ID\tTitle (shown during completion)
|
|
completions = append(completions, fmt.Sprintf("%s\t%s", issue.ID, issue.Title))
|
|
}
|
|
|
|
return completions, cobra.ShellCompDirectiveNoFileComp
|
|
}
|