/** * Utilities for generating incrementing numbered filenames. * Used by session-based artifact storage to create files like 001-feature.md. */ /** * The `-` prefix family: EXACTLY three digits, anchored at the start. The one * definition the counting side (`getNextNumber`), the writing side * (`buildNumberedFilename`) and the stripping side (`requestIdFromFileName`) all * read, so neither side can widen the family without the others. * * Three digits is what the writer pads to for every number it can hand out, and a * WIDER pattern on the counting side is the whole defect this constant closes: with * `^(\d+)-` the leading YEAR of a bare date-shaped name (`2026-10-15-`) reads * as a file number. Four digits is out of family by construction — `\d{3}` is * followed by `-`, and `2026-` has a digit there. */ export declare const NUMBERED_PREFIX_RE: RegExp; /** * Get the next available number in a directory. * Scans existing .md files and finds the highest IN-FAMILY numeric prefix. * Returns 1 if the directory is empty, missing, or holds no in-family name. * * A name whose leading digits are not a whole prefix in the family — a bare * date-shaped name, whose leading digits are a year — is ignored rather than * counted, so it can never move the answer. * * @param dirPath - Directory to scan for numbered files * @returns Next available number (1, 2, 3, ...) */ export declare function getNextNumber(dirPath: string): number; /** * Convert a human-readable description into the kebab-case slug used in * numbered artifact filenames. Lowercases, collapses non-alphanumerics to * `-`, trims leading/trailing dashes, and caps at `MAX_FILENAME_SLUG_LENGTH`. * * Exported separately so lookup paths (e.g. `request-artifact-service.ts`) * can compute the SAME slug the writer produced and match on-disk filenames * case-insensitively — the writer lowercases, so a mixed-case request id */ export declare function slugifyDescription(description: string): string; export declare function buildNumberedFilename(number: number, description: string): string; /** * The id a markdown artifact's filename carries, or null when the name is not a * markdown artifact at all. The READ side of `buildNumberedFilename`, in the same * module, so writer and reader cannot drift apart from each other. * * The prefix it strips is `NUMBERED_PREFIX_RE` — the same family `getNextNumber` * counts — so a name the writer produced always reads back as the id it was given. * A bare date-shaped stem carries no in-family prefix and is returned verbatim. * * The returned stem is not yet checked against the id pattern the artifact service * owns; a caller that needs a legal request id applies that there rather than the * pattern being imported here. */ export declare function requestIdFromFileName(fileName: string): string | null; /** * Get the next numbered file path in a directory. * Combines getNextNumber() and buildNumberedFilename(). * * @param dirPath - Directory to scan * @param description - Description for the filename * @returns Full path to the new numbered file */ export declare function getNextNumberedFilePath(dirPath: string, description: string): string;