source dump of claude code
at main 93 lines 2.9 kB view raw
1import { feature } from 'bun:bundle' 2import { getModelOptions } from '../../utils/model/modelOptions.js' 3import { isVoiceGrowthBookEnabled } from '../../voice/voiceModeEnabled.js' 4import { 5 getOptionsForSetting, 6 SUPPORTED_SETTINGS, 7} from './supportedSettings.js' 8 9export const DESCRIPTION = 'Get or set Claude Code configuration settings.' 10 11/** 12 * Generate the prompt documentation from the registry 13 */ 14export function generatePrompt(): string { 15 const globalSettings: string[] = [] 16 const projectSettings: string[] = [] 17 18 for (const [key, config] of Object.entries(SUPPORTED_SETTINGS)) { 19 // Skip model - it gets its own section with dynamic options 20 if (key === 'model') continue 21 // Voice settings are registered at build-time but gated by GrowthBook 22 // at runtime. Hide from model prompt when the kill-switch is on. 23 if ( 24 feature('VOICE_MODE') && 25 key === 'voiceEnabled' && 26 !isVoiceGrowthBookEnabled() 27 ) 28 continue 29 30 const options = getOptionsForSetting(key) 31 let line = `- ${key}` 32 33 if (options) { 34 line += `: ${options.map(o => `"${o}"`).join(', ')}` 35 } else if (config.type === 'boolean') { 36 line += `: true/false` 37 } 38 39 line += ` - ${config.description}` 40 41 if (config.source === 'global') { 42 globalSettings.push(line) 43 } else { 44 projectSettings.push(line) 45 } 46 } 47 48 const modelSection = generateModelSection() 49 50 return `Get or set Claude Code configuration settings. 51 52 View or change Claude Code settings. Use when the user requests configuration changes, asks about current settings, or when adjusting a setting would benefit them. 53 54 55## Usage 56- **Get current value:** Omit the "value" parameter 57- **Set new value:** Include the "value" parameter 58 59## Configurable settings list 60The following settings are available for you to change: 61 62### Global Settings (stored in ~/.claude.json) 63${globalSettings.join('\n')} 64 65### Project Settings (stored in settings.json) 66${projectSettings.join('\n')} 67 68${modelSection} 69## Examples 70- Get theme: { "setting": "theme" } 71- Set dark theme: { "setting": "theme", "value": "dark" } 72- Enable vim mode: { "setting": "editorMode", "value": "vim" } 73- Enable verbose: { "setting": "verbose", "value": true } 74- Change model: { "setting": "model", "value": "opus" } 75- Change permission mode: { "setting": "permissions.defaultMode", "value": "plan" } 76` 77} 78 79function generateModelSection(): string { 80 try { 81 const options = getModelOptions() 82 const lines = options.map(o => { 83 const value = o.value === null ? 'null/"default"' : `"${o.value}"` 84 return ` - ${value}: ${o.descriptionForModel ?? o.description}` 85 }) 86 return `## Model 87- model - Override the default model. Available options: 88${lines.join('\n')}` 89 } catch { 90 return `## Model 91- model - Override the default model (sonnet, opus, haiku, best, or full model ID)` 92 } 93}