From 9c0eba1d8ea5095e8760ed4d603c0fca8b05a405 Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Sun, 8 Feb 2026 03:57:29 +0000 Subject: [PATCH] bug: hidden parent causes tk prefix not to work --- features/ticket_creation.feature | 6 ++++++ ticket | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/features/ticket_creation.feature b/features/ticket_creation.feature index 7cc0776..a09a7a0 100644 --- a/features/ticket_creation.feature +++ b/features/ticket_creation.feature @@ -91,6 +91,12 @@ Feature: Ticket Creation Then the command should succeed And the created ticket should have a valid created timestamp + Scenario: Ticket ID has no special characters from dot-prefixed directory + Given I am in subdirectory ".agents" + When I run "ticket create 'Dot prefix test'" + Then the command should succeed + And the output should match pattern "^[a-z0-9]+-[a-z0-9]{4}$" + Scenario: Tickets directory created on demand Given the tickets directory does not exist When I run "ticket create 'First ticket'" diff --git a/ticket b/ticket index 1dedcec..3816769 100755 --- a/ticket +++ b/ticket @@ -82,6 +82,10 @@ generate_id() { local dir_name dir_name=$(basename "$(pwd)") + # Sanitize: lowercase, strip non-alphanumeric (keep - and _), strip leading -/_ + dir_name=$(echo "$dir_name" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9_-' | sed 's/^[-_]*//') + [[ -z "$dir_name" ]] && dir_name="tk" + # Extract first letter of each hyphenated/underscored segment local prefix prefix=$(echo "$dir_name" | sed 's/[-_]/ /g' | awk '{for(i=1;i<=NF;i++) printf substr($i,1,1)}')