/** * Worktree Detector * Issue #136: Phase 1 - Task 1.3 * * Provides utilities for detecting git worktrees and extracting issue numbers. * Used to automatically identify which worktree environment the CLI is running in. * * Security: Uses execFile instead of exec to prevent command injection. * * @module worktree-detector */ /** * Information about a detected worktree */ export interface WorktreeInfo { /** Issue number associated with the worktree */ issueNo: number; /** Absolute path to the worktree root */ path: string; /** Current git branch */ branch: string; } /** * Extract issue number from a worktree directory path * * @param dirPath - Directory path to check * @returns Issue number or null if not a worktree path * * @example * ```typescript * extractIssueNoFromPath('/home/user/repos/commandmate-issue-135'); // 135 * extractIssueNoFromPath('/home/user/repos/commandmate'); // null * ``` */ export declare function extractIssueNoFromPath(dirPath: string): number | null; /** * Extract issue number from a git branch name * * @param branchName - Git branch name * @returns Issue number or null if not found * * @example * ```typescript * extractIssueNoFromBranch('feature/135-add-worktree'); // 135 * extractIssueNoFromBranch('main'); // null * ``` */ export declare function extractIssueNoFromBranch(branchName: string): number | null; /** * Check if a directory is inside a git worktree * * @param dirPath - Directory path to check * @returns true if directory is inside a git repository */ export declare function isWorktreeDirectory(dirPath: string): Promise; /** * Detect if the current directory is within a CommandMate worktree * * Attempts to extract issue number from: * 1. Directory path (e.g., commandmate-issue-135) * 2. Git branch name (e.g., feature/135-description) * * @param dirPath - Directory path to check (defaults to cwd) * @returns WorktreeInfo if detected, null otherwise * * @example * ```typescript * const info = await detectCurrentWorktree(); * if (info) { * console.log(`Running in worktree for Issue #${info.issueNo}`); * } * ``` */ export declare function detectCurrentWorktree(dirPath?: string): Promise; /** * Detect worktree from environment or current directory * Convenience function that checks CM_ISSUE_NO env var first * * @returns WorktreeInfo if detected, null otherwise */ export declare function detectWorktreeContext(): Promise; //# sourceMappingURL=worktree-detector.d.ts.map