Documentation
¶
Overview ¶
Package utils provides utility functions for issue ID parsing and resolution.
Package utils provides utility functions for issue ID parsing and path handling.
Index ¶
- func CanonicalizePath(path string) string
- func ExtractIssueNumber(issueID string) int
- func ExtractIssuePrefix(issueID string) string
- func FindJSONLInDir(dbDir string) string
- func ParseIssueID(input string, prefix string) string
- func ResolvePartialID(ctx context.Context, store storage.Storage, input string) (string, error)
- func ResolvePartialIDs(ctx context.Context, store storage.Storage, inputs []string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalizePath ¶ added in v0.21.4
CanonicalizePath converts a path to its canonical form by: 1. Converting to absolute path 2. Resolving symlinks
If either step fails, it falls back to the best available form: - If symlink resolution fails, returns absolute path - If absolute path conversion fails, returns original path
This function is used to ensure consistent path handling across the codebase, particularly for BEADS_DIR environment variable processing.
func ExtractIssueNumber ¶
ExtractIssueNumber extracts the number from an issue ID like "bd-123" -> 123
func ExtractIssuePrefix ¶
ExtractIssuePrefix extracts the prefix from an issue ID like "bd-123" -> "bd" Uses the last hyphen before a numeric or hash-like suffix:
- "beads-vscode-1" -> "beads-vscode" (numeric suffix)
- "web-app-a3f8e9" -> "web-app" (hash suffix with digits)
- "my-cool-app-123" -> "my-cool-app" (numeric suffix)
- "bd-a3f" -> "bd" (3-char hash)
Falls back to first hyphen when suffix looks like an English word (4+ chars, no digits):
- "vc-baseline-test" -> "vc" (word-like suffix: "test" is not a hash)
- "bd-multi-part-id" -> "bd" (word-like suffix: "id" is too short but "part-id" path)
This distinguishes hash IDs (which may contain letters but have digits or are 3 chars) from multi-part IDs where the suffix after the first hyphen is the entire ID.
func FindJSONLInDir ¶ added in v0.26.1
FindJSONLInDir finds the JSONL file in the given .beads directory. It prefers issues.jsonl over other .jsonl files to prevent accidentally reading/writing to deletions.jsonl or merge artifacts (bd-tqo fix). Always returns a path (defaults to issues.jsonl if nothing suitable found).
Search order: 1. issues.jsonl (canonical name) 2. beads.jsonl (legacy support) 3. Any other .jsonl file except deletions/merge artifacts 4. Default to issues.jsonl
func ParseIssueID ¶ added in v0.20.0
ParseIssueID ensures an issue ID has the configured prefix. If the input already has the prefix (e.g., "bd-a3f8e9"), returns it as-is. If the input lacks the prefix (e.g., "a3f8e9"), adds the configured prefix. Works with hierarchical IDs too: "a3f8e9.1.2" → "bd-a3f8e9.1.2"
func ResolvePartialID ¶ added in v0.20.0
ResolvePartialID resolves a potentially partial issue ID to a full ID. Supports: - Full IDs: "bd-a3f8e9" or "a3f8e9" → "bd-a3f8e9" - Without hyphen: "bda3f8e9" or "wya3f8e9" → "bd-a3f8e9" - Partial IDs: "a3f8" → "bd-a3f8e9" (if unique match) - Hierarchical: "a3f8e9.1" → "bd-a3f8e9.1"
Returns an error if: - No issue found matching the ID - Multiple issues match (ambiguous prefix)
Types ¶
This section is empty.