//#region src/types.d.ts interface Theme { name: string; id: string; colors: { autoAccept: string; bashBorder: string; claude: string; claudeShimmer: string; claudeBlue_FOR_SYSTEM_SPINNER: string; claudeBlueShimmer_FOR_SYSTEM_SPINNER: string; permission: string; permissionShimmer: string; planMode: string; ide: string; promptBorder: string; promptBorderShimmer: string; text: string; inverseText: string; inactive: string; subtle: string; suggestion: string; remember: string; background: string; success: string; error: string; warning: string; warningShimmer: string; diffAdded: string; diffRemoved: string; diffAddedDimmed: string; diffRemovedDimmed: string; diffAddedWord: string; diffRemovedWord: string; diffAddedWordDimmed: string; diffRemovedWordDimmed: string; red_FOR_SUBAGENTS_ONLY: string; blue_FOR_SUBAGENTS_ONLY: string; green_FOR_SUBAGENTS_ONLY: string; yellow_FOR_SUBAGENTS_ONLY: string; purple_FOR_SUBAGENTS_ONLY: string; orange_FOR_SUBAGENTS_ONLY: string; pink_FOR_SUBAGENTS_ONLY: string; cyan_FOR_SUBAGENTS_ONLY: string; professionalBlue: string; rainbow_red: string; rainbow_orange: string; rainbow_yellow: string; rainbow_green: string; rainbow_blue: string; rainbow_indigo: string; rainbow_violet: string; rainbow_red_shimmer: string; rainbow_orange_shimmer: string; rainbow_yellow_shimmer: string; rainbow_green_shimmer: string; rainbow_blue_shimmer: string; rainbow_indigo_shimmer: string; rainbow_violet_shimmer: string; clawd_body: string; clawd_background: string; userMessageBackground: string; bashMessageBackgroundColor: string; memoryBackgroundColor: string; rate_limit_fill: string; rate_limit_empty: string; }; } interface ThinkingVerbsConfig { format: string; verbs: string[]; } interface ThinkingStyleConfig { reverseMirror: boolean; updateInterval: number; phases: string[]; } interface UserMessageDisplayConfig { format: string; styling: string[]; foregroundColor: string | 'default'; backgroundColor: string | 'default' | null; borderStyle: 'none' | 'single' | 'double' | 'round' | 'bold' | 'singleDouble' | 'doubleSingle' | 'classic' | 'topBottomSingle' | 'topBottomDouble' | 'topBottomBold'; borderColor: string; paddingX: number | 'default'; paddingY: number | 'default'; fitBoxToContent: boolean; } interface InputBoxConfig { removeBorder: boolean; } type TableFormat = 'default' | 'ascii' | 'clean' | 'clean-top-bottom'; type AutoModeClassifierModel = 'default' | 'sonnet' | 'haiku'; interface MiscConfig { showTweakccVersion: boolean; showPatchesApplied: boolean; expandThinkingBlocks: boolean; enableConversationTitle: boolean; hideStartupBanner: boolean; hideCtrlGToEdit: boolean; hideStartupClawd: boolean; increaseFileReadLimit: boolean; suppressLineNumbers: boolean; suppressRateLimitOptions: boolean; mcpConnectionNonBlocking: boolean; mcpServerBatchSize: number | null; statuslineThrottleMs: number | null; statuslineUseFixedInterval: boolean; tableFormat: TableFormat; enableSessionMemory: boolean; enableDreamMode: boolean; enableLeanMemoryTypes: boolean; fixSummarizeFromHere: boolean; fixRewindSummaryHeader: boolean; enableRememberSkill: boolean; tokenCountRounding: number | null; autoAcceptPlanMode: boolean; allowBypassPermissionsInSudo: boolean | null; suppressNativeInstallerWarning: boolean; filterScrollEscapeSequences: boolean; enableWorktreeMode: boolean; swapRipgrepForFff: boolean; allowCustomAgentModels: boolean; enableContextLimitOverride: boolean; enableModelCustomizations: boolean; enableVoiceMode: boolean; enableVoiceConciseOutput: boolean; enableChannelsMode: boolean; maxEffortDefault: boolean; autonomousOperationAllModels: boolean; autoModeClassifierModel: AutoModeClassifierModel; suppressDeferredTools: boolean; claudemdContextOncePerConversation: boolean; } interface InputPatternHighlighter { name: string; regex: string; regexFlags: string; format: string; styling: string[]; foregroundColor: string | null; backgroundColor: string | null; enabled: boolean; } interface Toolset { name: string; allowedTools: string[] | '*'; } interface SubagentModelsConfig { plan: string | null; explore: string | null; generalPurpose: string | null; } type RouterEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max'; interface RouterLevel { id: string; label: string; help: string; effort: RouterEffort; } interface ComplexityRouterConfig { enabled: boolean; pinPerTask: boolean; messageCap: number; assistantCap: number; timeoutMs: number; systemPrompt: string; levels: RouterLevel[]; } interface Settings { themes: Theme[]; thinkingVerbs: ThinkingVerbsConfig; thinkingStyle: ThinkingStyleConfig; userMessageDisplay: UserMessageDisplayConfig; inputBox: InputBoxConfig; misc: MiscConfig; toolsets: Toolset[]; defaultToolset: string | null; planModeToolset: string | null; subagentModels: SubagentModelsConfig; complexityRouter: ComplexityRouterConfig; inputPatternHighlighters: InputPatternHighlighter[]; inputPatternHighlightersTestText: string; claudeMdAltNames: string[] | null; } interface RemoteConfig { sourceUrl: string; dateFetched: string; settings: Partial; } interface TweakccConfig { ccVersion: string; ccInstallationDir?: string | null; ccInstallationPath?: string | null; lastModified: string; changesApplied: boolean; settings: Settings; hidePiebaldAnnouncement?: boolean; remoteConfig?: RemoteConfig; } //#endregion //#region src/lib/types.d.ts /** * tweakcc Library Types * * These are the public types exposed by the library API. */ /** * A Claude Code installation detected on the system. */ interface Installation { /** Path to cli.js (npm) or native binary */ path: string; /** Claude Code version, e.g., "2.1.0" */ version: string; /** Type of installation */ kind: 'npm' | 'native'; } //#endregion //#region src/lib/detection.d.ts /** * Find all Claude Code installations on the system by searching in PATH and * common install locations. */ declare function findAllInstallations(): Promise; /** * Options for {@link tryDetectInstallation}. * * @example * ```typescript * import { tryDetectInstallation, type DetectInstallationOptions } from 'tweakcc'; * * const opts: DetectInstallationOptions = { interactive: true }; * const installation = await tryDetectInstallation(opts); * ``` */ interface DetectInstallationOptions { /** Explicit path to a Claude Code installation — skips auto-detection. */ path?: string; /** * Show the interactive picker when multiple installations are found, instead * of throwing with the list. Default: `false`. */ interactive?: boolean; } /** * Attempts to detect the user's preferred Claude Code installation. Detection procedure: * 0. options.path * 1. Uses $TWEAKCC_CC_INSTALLATION_PATH if set. * 2. Uses ccInstallationPath in tweakcc config. * 3. Discovers installation from `claude` in PATH * 4. Looks in hard-coded search paths: * a. If the search yields one installation, uses it * b. If it yields multiple and options.interactive is true, display a picker * via showInteractiveInstallationPicker(). * @returns The selected installation. * @throws If user cancels via Esc. */ declare function tryDetectInstallation(options?: DetectInstallationOptions): Promise; /** * Prompts the user to select one of the specified Claude Code installations * interactively using the same UI tweakcc uses, powered by [Ink + React](https://github.com/vadimdemedes/ink). */ declare function showInteractiveInstallationPicker(candidates: Installation[]): Promise; //#endregion //#region src/lib/content.d.ts /** * Read Claude Code's JavaScript content. * * - npm installs: reads cli.js directly * - native installs: extracts embedded JS from binary * * @param installation - The installation to read from * @returns An object with `content` (the JavaScript as a string) and * `clearBytecode`, a flag that must be passed back to {@link writeContent}. * It is `true` only for native Bun installs whose embedded bytecode cache * must be invalidated after the JS changes; always `false` for npm installs. */ declare function readContent(installation: Installation): Promise<{ content: string; clearBytecode: boolean; }>; /** * Write modified JavaScript content back to Claude Code. * * - npm installs: writes to cli.js (handles permissions, hard links) * - native installs: repacks JS into binary * * @param installation - The installation to write to * @param content - The modified JavaScript content * @param clearBytecode - Pass the value returned by {@link readContent}. For * native Bun installs it clears the embedded bytecode cache so the new JS is * re-parsed (stale bytecode would otherwise keep running the OLD code); * ignored for npm installs. */ declare function writeContent(installation: Installation, content: string, clearBytecode: boolean): Promise; //#endregion //#region src/lib/backup.d.ts /** * Backup & Restore Utilities * * Generic file backup/restore with proper handling of permissions and hard links. * These are low-level utilities - the caller manages where backups are stored. */ /** * Backup a file to a specified location. * * Creates parent directories if needed. * Preserves the original file - this is a copy operation. * * @param sourcePath - Path to the file to backup * @param backupPath - Where to store the backup */ declare function backupFile(sourcePath: string, backupPath: string): Promise; /** * Restore a file from a backup. * * Handles: * - Breaking hard links (common with pnpm installations) * - Preserving file permissions * * @param backupPath - Path to the backup file * @param targetPath - Where to restore the file * @throws If backup file doesn't exist */ declare function restoreBackup(backupPath: string, targetPath: string): Promise; //#endregion //#region src/lib/config.d.ts /** * Get tweakcc's config directory path. * * Respects TWEAKCC_CONFIG_DIR environment variable. * Falls back to ~/.tweakcc, ~/.claude/tweakcc, or $XDG_CONFIG_HOME/tweakcc. * * @returns Absolute path to config directory */ declare function getTweakccConfigDir(): string; /** * Get tweakcc's config file path. */ declare function getTweakccConfigPath(): string; /** * Get tweakcc's system prompts directory. * * This is where tweakcc stores editable markdown files for system prompts. */ declare function getTweakccSystemPromptsDir(): string; /** * Read tweakcc's config file. */ declare function readTweakccConfig(): Promise; //#endregion //#region src/lib/index.d.ts /** * Helper utilities for writing patches against minified code. * * Includes functions to find minified variable names and utilities for * performing replacements with diff output. * * @example * ```typescript * const reactVar = helpers.getReactVar(content); * if (reactVar) { * content = content.replace( * new RegExp(`${reactVar}\\.createElement`), * // ... * ); * } * * // Clear caches when processing multiple files * helpers.clearCaches(); * ``` */ declare const helpers: { findChalkVar: (fileContents: string) => string | undefined; getModuleLoaderFunction: (fileContents: string) => string | undefined; getReactVar: (fileContents: string) => string | undefined; getRequireFuncName: (fileContents: string) => string; findTextComponent: (fileContents: string) => string | undefined; findBoxComponent: (fileContents: string) => string | undefined; clearCaches: () => void; globalReplace: (content: string, pattern: RegExp, replacement: string | ((substring: string, ...args: unknown[]) => string)) => string; showDiff: (oldFileContents: string, newFileContents: string, injectedText: string, startIndex: number, endIndex: number, numContextChars?: number) => void; }; //#endregion export { type DetectInstallationOptions, type Installation, type Settings, type TweakccConfig, backupFile, findAllInstallations, getTweakccConfigDir, getTweakccConfigPath, getTweakccSystemPromptsDir, helpers, readContent, readTweakccConfig, restoreBackup, showInteractiveInstallationPicker, tryDetectInstallation, writeContent };