@@ -5,6 +5,7 @@ import type { ClaudeSettings } from "../types/index.js";
55
66const SETTINGS_DIR = ".claude" ;
77const SETTINGS_FILE = "settings.json" ;
8+ const LOCAL_SETTINGS_FILE = "settings.local.json" ;
89
910export async function findClaudeDirectory ( ) : Promise < string | null > {
1011 let currentDir = process . cwd ( ) ;
@@ -26,22 +27,23 @@ export async function findClaudeDirectory(): Promise<string | null> {
2627 return null ;
2728}
2829
29- export async function getSettingsPath ( ) : Promise < string > {
30+ export async function getSettingsPath ( isLocal ?: boolean ) : Promise < string > {
3031 const claudeDir = await findClaudeDirectory ( ) ;
32+ const fileName = isLocal ? LOCAL_SETTINGS_FILE : SETTINGS_FILE ;
3133
3234 if ( ! claudeDir ) {
3335 // If no .claude directory found, create one in current directory
3436 const currentClaudeDir = join ( process . cwd ( ) , SETTINGS_DIR ) ;
3537 await fs . mkdir ( currentClaudeDir , { recursive : true } ) ;
36- return join ( currentClaudeDir , SETTINGS_FILE ) ;
38+ return join ( currentClaudeDir , fileName ) ;
3739 }
3840
39- return join ( claudeDir , SETTINGS_FILE ) ;
41+ return join ( claudeDir , fileName ) ;
4042}
4143
42- export async function readSettings ( ) : Promise < ClaudeSettings | null > {
44+ export async function readSettings ( isLocal ?: boolean ) : Promise < ClaudeSettings | null > {
4345 try {
44- const settingsPath = await getSettingsPath ( ) ;
46+ const settingsPath = await getSettingsPath ( isLocal ) ;
4547 const content = await fs . readFile ( settingsPath , "utf-8" ) ;
4648 const data = JSON . parse ( content ) ;
4749 return ClaudeSettingsSchema . parse ( data ) ;
@@ -53,14 +55,14 @@ export async function readSettings(): Promise<ClaudeSettings | null> {
5355 }
5456}
5557
56- export async function writeSettings ( settings : ClaudeSettings ) : Promise < void > {
57- const settingsPath = await getSettingsPath ( ) ;
58+ export async function writeSettings ( settings : ClaudeSettings , isLocal ?: boolean ) : Promise < void > {
59+ const settingsPath = await getSettingsPath ( isLocal ) ;
5860 const validated = ClaudeSettingsSchema . parse ( settings ) ;
5961 await fs . writeFile ( settingsPath , JSON . stringify ( validated , null , 2 ) , "utf-8" ) ;
6062}
6163
62- export async function createBackup ( ) : Promise < string > {
63- const settingsPath = await getSettingsPath ( ) ;
64+ export async function createBackup ( isLocal ?: boolean ) : Promise < string > {
65+ const settingsPath = await getSettingsPath ( isLocal ) ;
6466 const timestamp = new Date ( ) . toISOString ( ) . replace ( / [: .] / g, "-" ) ;
6567 const backupPath = settingsPath . replace ( ".json" , `.backup-${ timestamp } .json` ) ;
6668
0 commit comments