Modernize codebase by removing .js imports and changes to the tsconfig (#328)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Benjy
2026-01-02 14:08:27 -07:00
committed by GitHub
co-authored by coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
parent 541e0271e5
commit 7ce5bcbe7c
64 changed files with 250 additions and 291 deletions
+5 -10
View File
@@ -5,16 +5,11 @@ import path from 'node:path';
import { EOL } from 'node:os';
import chalk from 'chalk';
import {
Settings,
Theme,
ThinkingVerbsConfig,
TweakccConfig,
} from './types.js';
import { debug, expandTilde } from './utils.js';
import { hasUnappliedSystemPromptChanges } from './systemPromptHashIndex.js';
import { migrateUserMessageDisplayToV320 } from './migration.js';
import { DEFAULT_SETTINGS } from './defaultSettings.js';
import { Settings, Theme, ThinkingVerbsConfig, TweakccConfig } from './types';
import { debug, expandTilde } from './utils';
import { hasUnappliedSystemPromptChanges } from './systemPromptHashIndex';
import { migrateUserMessageDisplayToV320 } from './migration';
import { DEFAULT_SETTINGS } from './defaultSettings';
// Support XDG Base Directory Specification with backward compatibility
// Priority:
+1 -1
View File
@@ -1,4 +1,4 @@
import { Settings } from './types.js';
import { Settings } from './types';
export const DEFAULT_SETTINGS: Settings = {
themes: [
+10 -10
View File
@@ -3,20 +3,20 @@ import { render } from 'ink';
import { Command } from 'commander';
import chalk from 'chalk';
import App from './ui/App.js';
import { CONFIG_FILE, readConfigFile } from './config.js';
import { enableDebug, enableVerbose } from './utils.js';
import { applyCustomization } from './patches/index.js';
import { preloadStringsFile } from './systemPromptSync.js';
import { migrateConfigIfNeeded } from './migration.js';
import { completeStartupCheck, startupCheck } from './startup.js';
import App from './ui/App';
import { CONFIG_FILE, readConfigFile } from './config';
import { enableDebug, enableVerbose } from './utils';
import { applyCustomization } from './patches/index';
import { preloadStringsFile } from './systemPromptSync';
import { migrateConfigIfNeeded } from './migration';
import { completeStartupCheck, startupCheck } from './startup';
import {
formatNotFoundError,
InstallationDetectionError,
selectAndSaveInstallation,
} from './installationDetection.js';
import { InstallationPicker } from './ui/components/InstallationPicker.js';
import { InstallationCandidate, StartupCheckInfo } from './types.js';
} from './installationDetection';
import { InstallationPicker } from './ui/components/InstallationPicker';
import { InstallationCandidate, StartupCheckInfo } from './types';
const main = async () => {
const program = new Command();
+4 -4
View File
@@ -5,10 +5,10 @@ import {
ensureConfigDir,
NATIVE_BINARY_BACKUP_FILE,
updateConfigFile,
} from './config.js';
import { clearAllAppliedHashes } from './systemPromptHashIndex.js';
import { debug, replaceFileBreakingHardLinks, doesFileExist } from './utils.js';
import { ClaudeCodeInstallationInfo } from './types.js';
} from './config';
import { clearAllAppliedHashes } from './systemPromptHashIndex';
import { debug, replaceFileBreakingHardLinks, doesFileExist } from './utils';
import { ClaudeCodeInstallationInfo } from './types';
export const backupClijs = async (ccInstInfo: ClaudeCodeInstallationInfo) => {
// Only backup cli.js for NPM installs (when cliPath is set)
+5 -8
View File
@@ -9,13 +9,10 @@ import {
hashFileInChunks,
doesFileExist,
compareSemverVersions,
} from './utils.js';
import { extractClaudeJsFromNativeInstallation } from './nativeInstallationLoader.js';
import {
CLIJS_SEARCH_PATHS,
NATIVE_SEARCH_PATHS,
} from './installationPaths.js';
import { CONFIG_FILE, updateConfigFile } from './config.js';
} from './utils';
import { extractClaudeJsFromNativeInstallation } from './nativeInstallationLoader';
import { CLIJS_SEARCH_PATHS, NATIVE_SEARCH_PATHS } from './installationPaths';
import { CONFIG_FILE, updateConfigFile } from './config';
import {
ClaudeCodeInstallationInfo,
FindInstallationOptions,
@@ -23,7 +20,7 @@ import {
InstallationKind,
InstallationSource,
TweakccConfig,
} from './types.js';
} from './types';
// ============================================================================
// Types
+1 -1
View File
@@ -1,6 +1,6 @@
import { globbySync } from 'globby';
import os from 'node:os';
import { debug } from './utils.js';
import { debug } from './utils';
export interface SearchPathInfo {
pattern: string;
+2 -2
View File
@@ -1,8 +1,8 @@
import path from 'node:path';
import fs from 'node:fs/promises';
import { TweakccConfig } from './types.js';
import { CONFIG_FILE, ensureConfigDir } from './config.js';
import { TweakccConfig } from './types';
import { CONFIG_FILE, ensureConfigDir } from './config';
/**
* In v3.2.0 we changed the user message display config. This function migrates the old config.
+1 -1
View File
@@ -5,7 +5,7 @@
import fs from 'node:fs';
import { execSync } from 'node:child_process';
import LIEF from 'node-lief';
import { isDebug, debug } from './utils.js';
import { isDebug, debug } from './utils';
/**
* Constants for Bun trailer and serialized layout sizes.
+3 -3
View File
@@ -9,9 +9,9 @@
import type {
extractClaudeJsFromNativeInstallation as ExtractFn,
repackNativeInstallation as RepackFn,
} from './nativeInstallation.js';
} from './nativeInstallation';
import { debug } from './utils.js';
import { debug } from './utils';
interface NativeInstallationModule {
extractClaudeJsFromNativeInstallation: typeof ExtractFn;
@@ -33,7 +33,7 @@ async function tryLoadNativeInstallationModule(): Promise<NativeInstallationModu
// First check if node-lief is available
await import('node-lief');
// If it is, dynamically import the module that uses it
cachedModule = await import('./nativeInstallation.js');
cachedModule = await import('./nativeInstallation');
return cachedModule;
} catch (err) {
debug(
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { showDiff } from './index.js';
import { showDiff } from './index';
const getContextLimitLocation = (oldFile: string): number | null => {
// Pattern: function funcName(paramName){if(paramName.includes("[1m]"))return 1e6;return 200000}
+2 -2
View File
@@ -1,8 +1,8 @@
// Conversation title management patch for Claude Code
// Adds ability to set conversation titles and persist them
import { showDiff, getReactVar, getRequireFuncName } from './index.js';
import { writeSlashCommandDefinition as writeSlashCmd } from './slashCommands.js';
import { showDiff, getReactVar, getRequireFuncName } from './index';
import { writeSlashCommandDefinition as writeSlashCmd } from './slashCommands';
// ============================================================================
// SUB PATCH 1: Add /title slash command
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.ts.
// Please see the note about writing patches in ./index
import { escapeIdent, LocationResult, showDiff } from './index.js';
import { escapeIdent, LocationResult, showDiff } from './index';
const getOpenDocumentLocation = (oldFile: string): LocationResult | null => {
// Step 1: Find `ensureServerStarted:[$\w]+`
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getCtrlGToEditPromptLocation = (
oldFile: string
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getStartupBannerLocation = (oldFile: string): LocationResult | null => {
// Find the createElement with isBeforeFirstMessage:!1
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { showDiff } from './index.js';
import { showDiff } from './index';
/**
* Find all Clawd component function body start indices.
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
/**
* Find the file read token limit (25000) that's associated with the system-reminder.
+31 -31
View File
@@ -5,18 +5,18 @@ import {
CONFIG_DIR,
NATIVE_BINARY_BACKUP_FILE,
updateConfigFile,
} from '../config.js';
import { ClaudeCodeInstallationInfo, TweakccConfig } from '../types.js';
} from '../config';
import { ClaudeCodeInstallationInfo, TweakccConfig } from '../types';
import {
isVerbose,
verbose,
debug,
replaceFileBreakingHardLinks,
} from '../utils.js';
} from '../utils';
import {
extractClaudeJsFromNativeInstallation,
repackNativeInstallation,
} from '../nativeInstallationLoader.js';
} from '../nativeInstallationLoader';
// Notes to patch-writers:
//
@@ -32,40 +32,40 @@ import {
// character such as ',' or ';' can speed up matching even further, e.g. down to 30ms.
//
import { writeShowMoreItemsInSelectMenus } from './showMoreItemsInSelectMenus.js';
import { writeThemes } from './themes.js';
import { writeContextLimit } from './contextLimit.js';
import { writeInputBoxBorder } from './inputBorderBox.js';
import { writeSpinnerNoFreeze } from './spinnerNoFreeze.js';
import { writeThinkerFormat } from './thinkerFormat.js';
import { writeThinkerSymbolMirrorOption } from './thinkerMirrorOption.js';
import { writeThinkerSymbolChars } from './thinkerSymbolChars.js';
import { writeThinkerSymbolSpeed } from './thinkerSymbolSpeed.js';
import { writeThinkerSymbolWidthLocation } from './thinkerSymbolWidth.js';
import { writeThinkerVerbs } from './thinkerVerbs.js';
import { writeUserMessageDisplay } from './userMessageDisplay.js';
import { writeVerboseProperty } from './verboseProperty.js';
import { writeModelCustomizations } from './modelSelector.js';
import { writeThinkingVisibility } from './thinkingVisibility.js';
import { writePatchesAppliedIndication } from './patchesAppliedIndication.js';
import { applySystemPrompts } from './systemPrompts.js';
import { writeFixLspSupport } from './fixLspSupport.js';
import { writeShowMoreItemsInSelectMenus } from './showMoreItemsInSelectMenus';
import { writeThemes } from './themes';
import { writeContextLimit } from './contextLimit';
import { writeInputBoxBorder } from './inputBorderBox';
import { writeSpinnerNoFreeze } from './spinnerNoFreeze';
import { writeThinkerFormat } from './thinkerFormat';
import { writeThinkerSymbolMirrorOption } from './thinkerMirrorOption';
import { writeThinkerSymbolChars } from './thinkerSymbolChars';
import { writeThinkerSymbolSpeed } from './thinkerSymbolSpeed';
import { writeThinkerSymbolWidthLocation } from './thinkerSymbolWidth';
import { writeThinkerVerbs } from './thinkerVerbs';
import { writeUserMessageDisplay } from './userMessageDisplay';
import { writeVerboseProperty } from './verboseProperty';
import { writeModelCustomizations } from './modelSelector';
import { writeThinkingVisibility } from './thinkingVisibility';
import { writePatchesAppliedIndication } from './patchesAppliedIndication';
import { applySystemPrompts } from './systemPrompts';
import { writeFixLspSupport } from './fixLspSupport';
import {
writeToolsets,
writeModeChangeUpdateToolset,
addSetStateFnAccessAtToolChangeComponentScope,
} from './toolsets.js';
import { writeConversationTitle } from './conversationTitle.js';
import { writeHideStartupBanner } from './hideStartupBanner.js';
import { writeHideCtrlGToEditPrompt } from './hideCtrlGToEditPrompt.js';
import { writeHideStartupClawd } from './hideStartupClawd.js';
import { writeIncreaseFileReadLimit } from './increaseFileReadLimit.js';
import { writeSuppressLineNumbers } from './suppressLineNumbers.js';
} from './toolsets';
import { writeConversationTitle } from './conversationTitle';
import { writeHideStartupBanner } from './hideStartupBanner';
import { writeHideCtrlGToEditPrompt } from './hideCtrlGToEditPrompt';
import { writeHideStartupClawd } from './hideStartupClawd';
import { writeIncreaseFileReadLimit } from './increaseFileReadLimit';
import { writeSuppressLineNumbers } from './suppressLineNumbers';
import {
restoreNativeBinaryFromBackup,
restoreClijsFromBackup,
} from '../installationBackup.js';
import { compareVersions } from '../systemPromptSync.js';
} from '../installationBackup';
import { compareVersions } from '../systemPromptSync';
export interface LocationResult {
startIndex: number;
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getInputBoxBorderLocation = (oldFile: string): LocationResult | null => {
// Find the SPECIFIC main input box border pattern
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { escapeIdent, showDiff } from './index.js';
import { escapeIdent, showDiff } from './index';
// Models to inject/make available.
// prettier-ignore
+1 -1
View File
@@ -6,7 +6,7 @@ import {
findTextComponent,
getReactVar,
showDiff,
} from './index.js';
} from './index';
/**
* PATCH 1: Finds the location of the version output pattern in Claude Code's cli.js
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getShowMoreItemsInSelectMenusLocation = (
oldFile: string
+1 -1
View File
@@ -1,6 +1,6 @@
// Utilities for working with slash commands in Claude Code
import { showDiff } from './index.js';
import { showDiff } from './index';
/**
* Find the end position of the slash command array using stack machine
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getSpinnerNoFreezeLocation = (oldFile: string): LocationResult | null => {
const wholePattern =
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
/**
* Find the location of the line number formatting function.
+7 -7
View File
@@ -1,18 +1,18 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { applySystemPrompts } from './systemPrompts.js';
import * as promptSync from '../systemPromptSync.js';
import * as systemPromptHashIndex from '../systemPromptHashIndex.js';
import { applySystemPrompts } from './systemPrompts';
import * as promptSync from '../systemPromptSync';
import * as systemPromptHashIndex from '../systemPromptHashIndex';
vi.mock('../systemPromptSync.js', async () => {
const actual = await vi.importActual('../systemPromptSync.js');
vi.mock('../systemPromptSync', async () => {
const actual = await vi.importActual('../systemPromptSync');
return {
...actual,
loadSystemPromptsWithRegex: vi.fn(),
};
});
vi.mock('../systemPromptHashIndex.js', async () => {
const actual = await vi.importActual('../systemPromptHashIndex.js');
vi.mock('../systemPromptHashIndex', async () => {
const actual = await vi.importActual('../systemPromptHashIndex');
return {
...actual,
setAppliedHash: vi.fn(),
+4 -4
View File
@@ -1,14 +1,14 @@
import chalk from 'chalk';
import { debug, verbose } from '../utils.js';
import { showDiff, PatchApplied } from './index.js';
import { debug, verbose } from '../utils';
import { showDiff, PatchApplied } from './index';
import {
loadSystemPromptsWithRegex,
reconstructContentFromPieces,
findUnescapedBackticks,
formatBacktickError,
getPromptFilePath,
} from '../systemPromptSync.js';
import { setAppliedHash, computeMD5Hash } from '../systemPromptHashIndex.js';
} from '../systemPromptSync';
import { setAppliedHash, computeMD5Hash } from '../systemPromptHashIndex';
/**
* Detects if the cli.js file uses Unicode escape sequences for non-ASCII characters.
+3 -3
View File
@@ -1,7 +1,7 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { Theme } from '../types.js';
import { LocationResult, showDiff } from './index.js';
import { Theme } from '../types';
import { LocationResult, showDiff } from './index';
function getThemesLocation(oldFile: string): {
switchStatement: LocationResult;
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerFormatLocation = (oldFile: string): LocationResult | null => {
const approxAreaPattern =
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerSymbolMirrorOptionLocation = (
oldFile: string
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerSymbolCharsLocation = (oldFile: string): LocationResult[] => {
const results = [];
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerSymbolSpeedLocation = (
oldFile: string
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerSymbolWidthLocation = (
oldFile: string
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getThinkerVerbsLocation = (oldFile: string): LocationResult | null => {
// This finds the folowing pattern:
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
/**
* Forces thinking blocks to be visible inline by default, ensuring thinking content
+4 -4
View File
@@ -1,4 +1,4 @@
// Please see the note about writing patches in ./index.ts.
// Please see the note about writing patches in ./index
import {
showDiff,
@@ -6,12 +6,12 @@ import {
findTextComponent,
findBoxComponent,
getReactVar,
} from './index.js';
} from './index';
import {
findSlashCommandListEndPosition,
writeSlashCommandDefinition as writeSlashCommandDefinitionToArray,
} from './slashCommands.js';
import { Toolset } from '../types.js';
} from './slashCommands';
import { Toolset } from '../types';
// ============================================================================
// UTILITY FUNCTIONS - Variable Discovery
+2 -2
View File
@@ -1,10 +1,10 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import {
findBoxComponent,
findChalkVar,
LocationResult,
showDiff,
} from './index.js';
} from './index';
const getUserMessageDisplayLocation = (
oldFile: string
+2 -2
View File
@@ -1,6 +1,6 @@
// Please see the note about writing patches in ./index.js.
// Please see the note about writing patches in ./index
import { LocationResult, showDiff } from './index.js';
import { LocationResult, showDiff } from './index';
const getVerbosePropertyLocation = (oldFile: string): LocationResult | null => {
const createElementPattern =
+7 -7
View File
@@ -3,25 +3,25 @@ import fs from 'node:fs/promises';
import {
findClaudeCodeInstallation,
getPendingCandidates,
} from './installationDetection.js';
import { doesFileExist } from './utils.js';
} from './installationDetection';
import { doesFileExist } from './utils';
import {
CLIJS_BACKUP_FILE,
CONFIG_DIR,
CONFIG_FILE,
NATIVE_BINARY_BACKUP_FILE,
readConfigFile,
} from './config.js';
import { debug } from './utils.js';
import { displaySyncResults, syncSystemPrompts } from './systemPromptSync.js';
} from './config';
import { debug } from './utils';
import { displaySyncResults, syncSystemPrompts } from './systemPromptSync';
import {
ClaudeCodeInstallationInfo,
FindInstallationOptions,
InstallationCandidate,
StartupCheckInfo,
TweakccConfig,
} from './types.js';
import { backupClijs, backupNativeBinary } from './installationBackup.js';
} from './types';
import { backupClijs, backupNativeBinary } from './installationBackup';
export interface StartupCheckResult {
startupCheckInfo: StartupCheckInfo | null;
+2 -2
View File
@@ -1,7 +1,7 @@
import * as fs from 'node:fs/promises';
import * as path from 'path';
import type { StringsFile } from './systemPromptSync.js';
import { PROMPT_CACHE_DIR } from './config.js';
import type { StringsFile } from './systemPromptSync';
import { PROMPT_CACHE_DIR } from './config';
/**
* Downloads the strings file for a given CC version from GitHub
+2 -5
View File
@@ -1,11 +1,8 @@
import * as fs from 'node:fs/promises';
import * as path from 'path';
import * as crypto from 'crypto';
import {
StringsFile,
reconstructContentFromPieces,
} from './systemPromptSync.js';
import { CONFIG_DIR } from './config.js';
import { StringsFile, reconstructContentFromPieces } from './systemPromptSync';
import { CONFIG_DIR } from './config';
/**
* Gets the path to the system prompt hash index file
+3 -3
View File
@@ -1,14 +1,14 @@
import * as fs from 'node:fs/promises';
import * as path from 'path';
import matter from 'gray-matter';
import { downloadStringsFile } from './systemPromptDownload.js';
import { downloadStringsFile } from './systemPromptDownload';
import {
storeHashes,
getPromptHash,
computeMD5Hash,
} from './systemPromptHashIndex.js';
} from './systemPromptHashIndex';
import chalk from 'chalk';
import { SYSTEM_PROMPTS_DIR } from './config.js';
import { SYSTEM_PROMPTS_DIR } from './config';
/**
* Prompt structure from strings-X.Y.Z.json files
+1 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import { compareSemverVersions } from '../utils.js';
import { compareSemverVersions } from '../utils';
describe('compareSemverVersions', () => {
it('should return positive when a > b (major)', () => {
+12 -12
View File
@@ -6,15 +6,15 @@ import path from 'node:path';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { WASMagic } from 'wasmagic';
import { ClaudeCodeInstallationInfo } from '../types.js';
import * as misc from '../utils.js';
import * as systemPromptHashIndex from '../systemPromptHashIndex.js';
import * as nativeInstallation from '../nativeInstallationLoader.js';
import { DEFAULT_SETTINGS } from '../defaultSettings.js';
import { CLIJS_SEARCH_PATHS } from '../installationPaths.js';
import { restoreClijsFromBackup } from '../installationBackup.js';
import { startupCheck } from '../startup.js';
import { findClaudeCodeInstallation } from '../installationDetection.js';
import { ClaudeCodeInstallationInfo } from '../types';
import * as misc from '../utils';
import * as systemPromptHashIndex from '../systemPromptHashIndex';
import * as nativeInstallation from '../nativeInstallationLoader';
import { DEFAULT_SETTINGS } from '../defaultSettings';
import { CLIJS_SEARCH_PATHS } from '../installationPaths';
import { restoreClijsFromBackup } from '../installationBackup';
import { startupCheck } from '../startup';
import { findClaudeCodeInstallation } from '../installationDetection';
import {
CONFIG_DIR,
CONFIG_FILE,
@@ -22,14 +22,14 @@ import {
readConfigFile,
updateConfigFile,
warnAboutMultipleConfigs,
} from '../config.js';
} from '../config';
vi.mock('wasmagic');
vi.mock('node:fs/promises');
vi.mock('node:child_process', () => ({
execSync: vi.fn(),
}));
vi.mock('../nativeInstallationLoader.js', () => ({
vi.mock('../nativeInstallationLoader', () => ({
extractClaudeJsFromNativeInstallation: vi.fn(),
repackNativeInstallation: vi.fn(),
}));
@@ -61,7 +61,7 @@ import {
createEperm,
createSymlinkStats,
createRegularStats,
} from './testHelpers.js';
} from './testHelpers';
describe('config.ts', () => {
let originalSearchPathsLength: number;
+4 -4
View File
@@ -2,10 +2,10 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import { describe, it, vi, expect } from 'vitest';
import { DEFAULT_SETTINGS } from '../defaultSettings.js';
import { readConfigFile } from '../config.js';
import { migrateConfigIfNeeded } from '../migration.js';
import { createEnoent } from './testHelpers.js';
import { DEFAULT_SETTINGS } from '../defaultSettings';
import { readConfigFile } from '../config';
import { migrateConfigIfNeeded } from '../migration';
import { createEnoent } from './testHelpers';
describe('userMessageDisplay migration', () => {
it('should migrate old prefix/message structure to new format string', async () => {
+9 -25
View File
@@ -44,9 +44,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up to ensure module is loaded with mocks
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the /usr/local/n/versions/node pattern in search paths
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -78,9 +76,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the /usr/local/nvm pattern in search paths
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -112,9 +108,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the ~/.nvm pattern in search paths
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -157,9 +151,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Should have multiple search paths, including ones after the failed one
expect(CLIJS_SEARCH_PATH_INFO.length).toBeGreaterThan(10);
@@ -191,9 +183,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up to ensure module is loaded with mocks
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the AppData/Roaming/nvm pattern in search paths (converted to backslashes)
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -225,9 +215,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the pnpm pattern in search paths (converted to backslashes)
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -261,9 +249,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find the fnm pattern in search paths (converted to backslashes)
const problematicPath = CLIJS_SEARCH_PATH_INFO.find(
@@ -310,9 +296,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
);
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import(
'../installationPaths.js'
);
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Should have multiple search paths, including ones after the failed one
expect(CLIJS_SEARCH_PATH_INFO.length).toBeGreaterThan(10);
@@ -332,7 +316,7 @@ describe('getClijsSearchPathsWithInfo - glob error handling', () => {
});
// Import after mocks are set up
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths.js');
const { CLIJS_SEARCH_PATH_INFO } = await import('../installationPaths');
// Find a glob pattern (should have expanded paths)
const globPattern = CLIJS_SEARCH_PATH_INFO.find(info => info.isGlob);
+12 -26
View File
@@ -1,10 +1,10 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import * as fs from 'node:fs/promises';
import * as promptSync from '../systemPromptSync.js';
import type { StringsPrompt, StringsFile } from '../systemPromptSync.js';
import * as promptSync from '../systemPromptSync';
import type { StringsPrompt, StringsFile } from '../systemPromptSync';
vi.mock('node:fs/promises');
vi.mock('../systemPromptDownload.js');
vi.mock('../systemPromptDownload');
const createEnoent = () => {
const error: NodeJS.ErrnoException = new Error(
@@ -695,10 +695,8 @@ Greet user as \${SETTINGS.preferredName}!`;
],
};
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const hashIndexModule = await import('../systemPromptHashIndex.js');
const { downloadStringsFile } = await import('../systemPromptDownload');
const hashIndexModule = await import('../systemPromptHashIndex');
vi.mocked(downloadStringsFile).mockResolvedValue(
mockOldStringsFile as StringsFile
@@ -769,10 +767,8 @@ Greet user as \${SETTINGS.preferredName}!`;
],
};
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const hashIndexModule = await import('../systemPromptHashIndex.js');
const { downloadStringsFile } = await import('../systemPromptDownload');
const hashIndexModule = await import('../systemPromptHashIndex');
vi.mocked(downloadStringsFile).mockResolvedValue(
mockStringsFile as StringsFile
@@ -807,9 +803,7 @@ Greet user as \${SETTINGS.preferredName}!`;
],
};
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const { downloadStringsFile } = await import('../systemPromptDownload');
vi.mocked(downloadStringsFile).mockResolvedValue(
mockStringsFile as StringsFile
);
@@ -828,9 +822,7 @@ Greet user as \${SETTINGS.preferredName}!`;
});
it('should throw error if download fails', async () => {
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const { downloadStringsFile } = await import('../systemPromptDownload');
vi.mocked(downloadStringsFile).mockRejectedValue(
new Error('Download failed')
);
@@ -920,9 +912,7 @@ Greet user as \${SETTINGS.preferredName}!`;
};
// Mock the download function to return our test data
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const { downloadStringsFile } = await import('../systemPromptDownload');
vi.mocked(downloadStringsFile).mockResolvedValue(mockStringsFile);
// Preload the strings file using the public API
@@ -971,9 +961,7 @@ Usage: \${MAX_TIMEOUT()} ms`;
};
// Mock the download function to return our test data
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const { downloadStringsFile } = await import('../systemPromptDownload');
vi.mocked(downloadStringsFile).mockResolvedValue(mockStringsFile);
// Preload the strings file using the public API
@@ -1035,9 +1023,7 @@ Version: <<CCVERSION>>, BUILD_TIME:"<<BUILD_TIME>>"`;
],
};
const { downloadStringsFile } = await import(
'../systemPromptDownload.js'
);
const { downloadStringsFile } = await import('../systemPromptDownload');
vi.mocked(downloadStringsFile).mockResolvedValue(mockStringsFile);
await promptSync.preloadStringsFile('1.0.0');
+13 -13
View File
@@ -1,31 +1,31 @@
import { useState, useEffect, createContext, useCallback } from 'react';
import { Box, useInput } from 'ink';
import { MainView } from './components/MainView.js';
import { ThemesView } from './components/ThemesView.js';
import { ThinkingVerbsView } from './components/ThinkingVerbsView.js';
import { ThinkingStyleView } from './components/ThinkingStyleView.js';
import { UserMessageDisplayView } from './components/UserMessageDisplayView.js';
import { MiscView } from './components/MiscView.js';
import { ToolsetsView } from './components/ToolsetsView.js';
import { MainView } from './components/MainView';
import { ThemesView } from './components/ThemesView';
import { ThinkingVerbsView } from './components/ThinkingVerbsView';
import { ThinkingStyleView } from './components/ThinkingStyleView';
import { UserMessageDisplayView } from './components/UserMessageDisplayView';
import { MiscView } from './components/MiscView';
import { ToolsetsView } from './components/ToolsetsView';
import {
MainMenuItem,
Settings,
StartupCheckInfo,
TweakccConfig,
} from '../types.js';
} from '../types';
import {
CONFIG_FILE,
readConfigFile,
SYSTEM_PROMPTS_DIR,
updateConfigFile,
} from '../config.js';
import { openInExplorer, revealFileInExplorer } from '../utils.js';
import { applyCustomization } from '../patches/index.js';
import { DEFAULT_SETTINGS } from '../defaultSettings.js';
} from '../config';
import { openInExplorer, revealFileInExplorer } from '../utils';
import { applyCustomization } from '../patches/index';
import { DEFAULT_SETTINGS } from '../defaultSettings';
import {
restoreNativeBinaryFromBackup,
restoreClijsFromBackup,
} from '../installationBackup.js';
} from '../installationBackup';
export const SettingsContext = createContext({
settings: DEFAULT_SETTINGS,
+1 -1
View File
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { Box, Text, useInput } from 'ink';
import Header from './Header.js';
import Header from './Header';
interface ChangeNameViewProps {
onBack: () => void;
+1 -1
View File
@@ -1,7 +1,7 @@
import { useState, useEffect, Fragment } from 'react';
import { Box, Text, useInput } from 'ink';
import { isValidColorFormat, normalizeColorToRgb } from '@/utils.js';
import { isValidColorFormat, normalizeColorToRgb } from '@/utils';
interface ColorPickerProps {
initialValue: string;
+2 -2
View File
@@ -1,5 +1,5 @@
import { Theme } from '@/types.js';
import { ColoredText } from './ThemePreview.js';
import { Theme } from '@/types';
import { ColoredText } from './ThemePreview';
interface ColoredColorNameProps {
colorKey: keyof Theme['colors'];
+2 -2
View File
@@ -2,8 +2,8 @@ import * as os from 'node:os';
import { useState } from 'react';
import { Box, Text, useInput } from 'ink';
import { InstallationCandidate } from '../../types.js';
import { CONFIG_DIR } from '@/config.js';
import { InstallationCandidate } from '../../types';
import { CONFIG_DIR } from '@/config';
interface InstallationPickerProps {
candidates: InstallationCandidate[];
+4 -4
View File
@@ -1,8 +1,8 @@
import { CONFIG_FILE } from '@/config.js';
import { MainMenuItem } from '@/types.js';
import { CONFIG_FILE } from '@/config';
import { MainMenuItem } from '@/types';
import { useContext, useState } from 'react';
import { SettingsContext } from '../App.js';
import { SelectInput, SelectItem } from './SelectInput.js';
import { SettingsContext } from '../App';
import { SelectInput, SelectItem } from './SelectInput';
const baseMenuItems: SelectItem[] = [
{
+5 -5
View File
@@ -3,12 +3,12 @@ import * as os from 'node:os';
import { Box, Text } from 'ink';
import Link from 'ink-link';
import { MainMenuItem } from '@/types.js';
import { CONFIG_DIR } from '@/config.js';
import { MainMenuItem } from '@/types';
import { CONFIG_DIR } from '@/config';
import Header from './Header.js';
import PiebaldAnnouncement from './PiebaldAnnouncement.js';
import MainMenu from './MainMenu.js';
import Header from './Header';
import PiebaldAnnouncement from './PiebaldAnnouncement';
import MainMenu from './MainMenu';
const TweakccHeader = () => (
<Box flexDirection="row">
+2 -2
View File
@@ -1,7 +1,7 @@
import { Box, Text, useInput } from 'ink';
import { useContext, useState, useMemo } from 'react';
import { SettingsContext } from '../App.js';
import Header from './Header.js';
import { SettingsContext } from '../App';
import Header from './Header';
interface MiscViewProps {
onSubmit: () => void;
+7 -7
View File
@@ -1,14 +1,14 @@
import { useState, useContext, useCallback } from 'react';
import { Box, Text, useInput } from 'ink';
import { Theme } from '@/types.js';
import { isValidColorFormat, normalizeColorToRgb } from '@/utils.js';
import { Theme } from '@/types';
import { isValidColorFormat, normalizeColorToRgb } from '@/utils';
import { SettingsContext } from '../App.js';
import { ThemePreview, ColoredText } from './ThemePreview.js';
import { ColoredColorName } from './ColoredColorName.js';
import { ColorPicker } from './ColorPicker.js';
import Header from './Header.js';
import { SettingsContext } from '../App';
import { ThemePreview, ColoredText } from './ThemePreview';
import { ColoredColorName } from './ColoredColorName';
import { ColorPicker } from './ColorPicker';
import Header from './Header';
interface ThemeEditViewProps {
onBack: () => void;
+3 -3
View File
@@ -4,10 +4,10 @@ import { Box, Text } from 'ink';
import chalk from 'chalk';
import React, { useState, useEffect, useContext } from 'react';
import { Theme } from '@/types.js';
import { getClaudeSubscriptionType, getSelectedModel } from '@/utils.js';
import { Theme } from '@/types';
import { getClaudeSubscriptionType, getSelectedModel } from '@/utils';
import { SettingsContext } from '../App.js';
import { SettingsContext } from '../App';
interface ThemePreviewProps {
theme: Theme;
+6 -6
View File
@@ -1,13 +1,13 @@
import { useState, useContext } from 'react';
import { Box, Text, useInput } from 'ink';
import { Theme } from '@/types.js';
import { DEFAULT_SETTINGS } from '@/defaultSettings.js';
import { Theme } from '@/types';
import { DEFAULT_SETTINGS } from '@/defaultSettings';
import { SettingsContext } from '../App.js';
import { ThemeEditView } from './ThemeEditView.js';
import { ThemePreview } from './ThemePreview.js';
import Header from './Header.js';
import { SettingsContext } from '../App';
import { ThemeEditView } from './ThemeEditView';
import { ThemePreview } from './ThemePreview';
import Header from './Header';
function generateThemeItems(themes: Theme[]): string[] {
return themes.map(theme => `${theme.name} (${theme.id})`);
+4 -4
View File
@@ -1,11 +1,11 @@
import { useState, useEffect, useContext } from 'react';
import { Box, Text, useInput } from 'ink';
import { getCurrentClaudeCodeTheme } from '@/utils.js';
import { DEFAULT_SETTINGS } from '@/defaultSettings.js';
import { getCurrentClaudeCodeTheme } from '@/utils';
import { DEFAULT_SETTINGS } from '@/defaultSettings';
import { SettingsContext } from '../App.js';
import Header from './Header.js';
import { SettingsContext } from '../App';
import Header from './Header';
interface ThinkingStyleViewProps {
onBack: () => void;
+4 -4
View File
@@ -1,11 +1,11 @@
import { useContext, useState } from 'react';
import { Box, Text, useInput } from 'ink';
import { getCurrentClaudeCodeTheme } from '@/utils.js';
import { DEFAULT_SETTINGS } from '@/defaultSettings.js';
import { getCurrentClaudeCodeTheme } from '@/utils';
import { DEFAULT_SETTINGS } from '@/defaultSettings';
import Header from './Header.js';
import { SettingsContext } from '../App.js';
import Header from './Header';
import { SettingsContext } from '../App';
interface ThinkingVerbsViewProps {
onBack: () => void;
+2 -2
View File
@@ -1,7 +1,7 @@
import { useState, useContext, useEffect } from 'react';
import { Box, Text, useInput } from 'ink';
import { SettingsContext } from '../App.js';
import Header from './Header.js';
import { SettingsContext } from '../App';
import Header from './Header';
interface ToolsetEditViewProps {
toolsetIndex: number;
+6 -6
View File
@@ -1,13 +1,13 @@
import { useState, useContext } from 'react';
import { Box, Text, useInput } from 'ink';
import { Toolset } from '@/types.js';
import { getCurrentClaudeCodeTheme } from '@/utils.js';
import { DEFAULT_SETTINGS } from '@/defaultSettings.js';
import { Toolset } from '@/types';
import { getCurrentClaudeCodeTheme } from '@/utils';
import { DEFAULT_SETTINGS } from '@/defaultSettings';
import { ToolsetEditView } from './ToolsetEditView.js';
import Header from './Header.js';
import { SettingsContext } from '../App.js';
import { ToolsetEditView } from './ToolsetEditView';
import Header from './Header';
import { SettingsContext } from '../App';
interface ToolsetsViewProps {
onBack: () => void;
+7 -7
View File
@@ -1,14 +1,14 @@
import { useState, useContext } from 'react';
import { Box, BoxProps, Text, useInput } from 'ink';
import { UserMessageDisplayConfig } from '@/types.js';
import { getCurrentClaudeCodeTheme } from '@/utils.js';
import { DEFAULT_SETTINGS } from '@/defaultSettings.js';
import { UserMessageDisplayConfig } from '@/types';
import { getCurrentClaudeCodeTheme } from '@/utils';
import { DEFAULT_SETTINGS } from '@/defaultSettings';
import { ColorPicker } from './ColorPicker.js';
import { SettingsContext } from '../App.js';
import Header from './Header.js';
import { useNonInitialEffect } from '../hooks/useNonInitialEffect.js';
import { ColorPicker } from './ColorPicker';
import { SettingsContext } from '../App';
import Header from './Header';
import { useNonInitialEffect } from '../hooks/useNonInitialEffect';
type Writable<T> = { -readonly [P in keyof T]: T[P] };
+2 -2
View File
@@ -4,8 +4,8 @@ import * as path from 'path';
import * as os from 'os';
import * as child_process from 'child_process';
import * as crypto from 'crypto';
import { Theme } from './types.js';
import { CUSTOM_MODELS } from './patches/modelSelector.js';
import { Theme } from './types';
import { CUSTOM_MODELS } from './patches/modelSelector';
let isDebugModeOn = false;
let isVerboseModeOn = false;
+2 -2
View File
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"module": "ESNext",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
@@ -12,7 +12,7 @@
"sourceMap": true,
"resolveJsonModule": true,
"jsx": "react-jsx",
"moduleResolution": "node16",
"moduleResolution": "Bundler",
"baseUrl": ".",
"noEmit": true,
"paths": {