prompt.ts 2.8 KB

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