/** * Utility functions for spec-kit * * Provides task ID builders, regex utilities, file system utilities, * git utilities, ticket reference detection, and other helper functions * used throughout the spec-kit package. */ import type { TaskIdConfig } from '../types/task.js'; export { FileNotFoundError, PermissionError, RepoNotFoundError, exists, isDirectory, isFile, readFile, writeFile, mkdir, readDir, findRepoRoot, } from './fs.js'; export { isGitRepo, getCurrentBranch } from './git.js'; export { generateSlug, STOP_WORDS } from './slug.js'; export type { SlugOptions } from './slug.js'; export { findNextFeatureNumber, padFeatureNumber } from './numbering.js'; export { detectTicketRef } from './detect-ticket-ref.js'; export { parseClarificationsFile, formatQuestion, formatBatch, generateBatchTimestamp, countQuestions, findQuestion, updateAnswerInContent, CLARIFICATIONS_FILE_HEADER, } from './clarification-parser.js'; export type { ParsedClarificationsFile } from './clarification-parser.js'; export { parseTasksContent, parseTaskGroups, parseTasksFile, detectTaskFormat, filterEligibleTasks, filterEligibleGroups, updateTasksWithIssueLinks, countTasks, countGroups, } from './task-parser.js'; export type { TaskFormat, ParseTasksResult, IssueLinksMap, } from './task-parser.js'; export { validateDependencies, validateTaskDependencies, detectCircularDependencies, isValidDAG, isValidTaskDAG, getDependencies, getDependents, getAllDependencies, findRootItems, findLeafItems, } from './dependency.js'; export type { DependencyItem } from './dependency.js'; export { groupTasks, groupByTask, groupByStory, groupByPhase, topologicalSort, buildIssueBody, buildIssueBodyForGroup, convertGroupEntriesToTaskGroups, } from './grouping.js'; export type { SortableTaskGroup } from './grouping.js'; export { checkGhCli, createIssue, searchIssues, getIssueLabels, getRepoInfo, findExistingIssue, GhCliError, } from './github-cli.js'; export type { GhCliCheckResult, CreateIssueOptions, CreatedIssueResult, SearchIssuesOptions, SearchResultItem, GhCliErrorCode, } from './github-cli.js'; /** * Build a task ID from a number. * * @param num - Task number (1-indexed) * @param config - Optional task ID configuration * @returns Formatted task ID (e.g., "T001") * * @example * ```typescript * buildTaskId(1); // "T001" * buildTaskId(42); // "T042" * buildTaskId(1, { idPrefix: 'TASK', idPadding: 4, idSeparator: '-' }); * // "TASK-0001" * ``` */ export declare function buildTaskId(num: number, config?: Partial): string; /** * Build a task group ID from a number. * * @param num - Group number (1-indexed) * @param config - Optional task ID configuration * @returns Formatted task group ID (e.g., "TG-001") * * @example * ```typescript * buildTaskGroupId(1); // "TG-001" * buildTaskGroupId(42); // "TG-042" * buildTaskGroupId(1, { groupPrefix: 'GROUP', groupSeparator: '_', groupPadding: 4 }); * // "GROUP_0001" * ``` */ export declare function buildTaskGroupId(num: number, config?: Partial): string; /** * Build a regex pattern that matches task IDs exactly. * * @param config - Optional task ID configuration * @returns RegExp that matches a task ID (e.g., /^T\d{3}$/) * * @example * ```typescript * const pattern = buildTaskIdPattern(); * pattern.test('T001'); // true * pattern.test('T1234'); // false (wrong padding) * pattern.test('TASK001'); // false (wrong prefix) * ``` */ export declare function buildTaskIdPattern(config?: Partial): RegExp; /** * Build a regex pattern that matches task group IDs exactly. * * @param config - Optional task ID configuration * @returns RegExp that matches a task group ID (e.g., /^TG-\d{3}$/) * * @example * ```typescript * const pattern = buildTaskGroupIdPattern(); * pattern.test('TG-001'); // true * pattern.test('TG001'); // false (missing separator) * ``` */ export declare function buildTaskGroupIdPattern(config?: Partial): RegExp; /** * Build a regex pattern for searching task IDs in text (not anchored). * * @param config - Optional task ID configuration * @returns RegExp that finds task IDs in text * * @example * ```typescript * const pattern = buildTaskIdSearchPattern(); * const text = 'Depends on T001 and T002'; * const matches = text.match(pattern); // ['T001', 'T002'] * ``` */ export declare function buildTaskIdSearchPattern(config?: Partial): RegExp; /** * Build a regex pattern for searching task group IDs in text (not anchored). * * @param config - Optional task ID configuration * @returns RegExp that finds task group IDs in text * * @example * ```typescript * const pattern = buildTaskGroupIdSearchPattern(); * const text = 'See TG-001 and TG-002'; * const matches = text.match(pattern); // ['TG-001', 'TG-002'] * ``` */ export declare function buildTaskGroupIdSearchPattern(config?: Partial): RegExp; /** * Escape special regex characters in a string. * * @param str - String to escape * @returns Escaped string safe for use in RegExp * * @example * ```typescript * escapeRegex('foo.bar'); // "foo\\.bar" * escapeRegex('T-001'); // "T\\-001" * escapeRegex('[test]'); // "\\[test\\]" * ``` */ export declare function escapeRegex(str: string): string; /** * Parse a task ID to extract the number. * * @param taskId - Task ID to parse (e.g., "T001") * @param config - Optional task ID configuration * @returns Parsed number or null if invalid * * @example * ```typescript * parseTaskIdNumber('T001'); // 1 * parseTaskIdNumber('T042'); // 42 * parseTaskIdNumber('invalid'); // null * ``` */ export declare function parseTaskIdNumber(taskId: string, config?: Partial): number | null; /** * Parse a task group ID to extract the number. * * @param groupId - Group ID to parse (e.g., "TG-001") * @param config - Optional task ID configuration * @returns Parsed number or null if invalid * * @example * ```typescript * parseTaskGroupIdNumber('TG-001'); // 1 * parseTaskGroupIdNumber('TG-042'); // 42 * parseTaskGroupIdNumber('invalid'); // null * ``` */ export declare function parseTaskGroupIdNumber(groupId: string, config?: Partial): number | null; /** * Validate that a string is a valid task ID. * * @param taskId - String to validate * @param config - Optional task ID configuration * @returns True if valid task ID * * @example * ```typescript * isValidTaskId('T001'); // true * isValidTaskId('T1'); // false * isValidTaskId('TASK001'); // false * ``` */ export declare function isValidTaskId(taskId: string, config?: Partial): boolean; /** * Validate that a string is a valid task group ID. * * @param groupId - String to validate * @param config - Optional task ID configuration * @returns True if valid task group ID * * @example * ```typescript * isValidTaskGroupId('TG-001'); // true * isValidTaskGroupId('TG001'); // false * isValidTaskGroupId('T-001'); // false * ``` */ export declare function isValidTaskGroupId(groupId: string, config?: Partial): boolean; //# sourceMappingURL=index.d.ts.map