/** * Token Expansion Utility * * Provides consistent token substitution for configuration files and prompts. * Supports date/time tokens, git repository tokens, and path tokens. */ /** * List of known token names */ export declare const KNOWN_TOKENS: readonly ["today", "now", "repo_root", "workspace_root", "branch", "commit"]; /** * Token definitions */ export interface TokenContext { /** Override for today's date (for testing) */ today?: Date; /** Override for current time (for testing) */ now?: Date; /** Override for repo root path (for testing) */ repoRoot?: string; /** Override for workspace root path (for testing) */ workspaceRoot?: string; /** Override for git branch (for testing) */ branch?: string; /** Override for git commit (for testing) */ commit?: string; } /** * Expand tokens in a string * * @param input - String that may contain tokens like {{today}}, {{now}}, etc. * @param context - Optional context for overriding token values (useful for testing) * @returns String with tokens replaced by their values * * Supported tokens: * - `{{today}}` → YYYY-MM-DD (e.g., 2025-11-09) * - `{{now}}` → YYYYMMDDTHHMMSS (e.g., 20251109T123456) * - `{{repo_root}}` → Detected repository root (first parent with .git/) * - `{{workspace_root}}` → Multi-folder workspace root (when available) * - `{{branch}}` → Current git branch * - `{{commit}}` → Current git commit SHA (short form) * * @example * ```ts * const path = expandTokens("{{repo_root}}/.smartergpt/deliverables/weave-{{today}}-{{now}}"); * // => "/path/to/repo/.smartergpt/deliverables/weave-2025-11-09-20251109T123456" * * const filename = expandTokens("umbrella-{{today}}-{{now}}.md"); * // => "umbrella-2025-11-09-20251109T123456.md" * ``` */ export declare function expandTokens(input: string, context?: TokenContext): string; /** * Check if a string contains any tokens * * @param input - String to check * @returns true if the string contains any expandable tokens */ export declare function hasTokens(input: string): boolean; /** * Extract all tokens found in a string * * @param input - String to analyze * @returns Array of token names found (without delimiters) */ export declare function extractTokens(input: string): string[]; /** * Expand tokens in all string values of an object (recursively) * * @param obj - Object that may contain tokens in string values * @param context - Optional context for overriding token values * @returns New object with tokens expanded in all string values * * @example * ```ts * const config = { * deliverables: "{{repo_root}}/.smartergpt/deliverables/{{today}}", * created: "{{today}}T12:00:00Z", * metadata: { * branch: "{{branch}}", * commit: "{{commit}}" * } * }; * * const expanded = expandTokensInObject(config); * // All string values will have tokens expanded * ``` */ export declare function expandTokensInObject(obj: T, context?: TokenContext): T;