Fix 3 bugs from issue #174 that caused silent failure loop:
1. kugetsu-log.sh: Fix json.loads with newlines
- Previously, notifications JSON was embedded in a single-quoted Python
string literal, but newlines in the JSON broke the Python parser.
- Fix: Pass JSON via stdin to Python instead of embedding in string.
2. kugetsu-queue-daemon.sh: Create logs directory during init
- The logs/ directory ($LOGS_DIR) was never created during kugetsu init.
- Fix: Add mkdir -p for LOGS_DIR, WORKTREES_DIR, QUEUE_DIR, and
QUEUE_ITEMS_DIR to ensure_dirs() and ensure_queue_dirs().
3. kugetsu: Fix parse_issue_ref_from_message URL parsing
- The function used buggy grep/sed to parse URLs like
#158
- Fix: Use bash regex (=~) for reliable URL parsing with proper
capture groups.
Additional improvements:
- ensure_dirs() now creates all necessary directories instead of just
SESSIONS_DIR
- ensure_queue_dirs() now also creates QUEUE_DIR and LOGS_DIR
- parse_issue_ref_from_message uses consistent bash regex approach
for all URL patterns
Split the monolithic kugetsu script into modular components:
Modules created:
- kugetsu-config.sh - Config/env loading and global variables
- kugetsu-index.sh - Index.json read/write via JSON
- kugetsu-worktree.sh - Git worktree operations
- kugetsu-log.sh - Structured logging and notifications
- kugetsu-session.sh - Session create/fork/destroy logic
- kugetsu-queue-daemon.sh - Queue daemon subprocess
Main script (kugetsu) is now a thin dispatcher that sources all modules.
Acceptance Criteria:
- All existing commands work exactly as before
- Main script sources modules
- Each module is independently testable
Fixes#116