File size: 23,296 Bytes
d810ed8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type {
MCPServerConfig,
BugCommandSettings,
TelemetrySettings,
AuthType,
ChatCompressionSettings,
} from '@google/gemini-cli-core';
import type { CustomTheme } from '../ui/themes/theme.js';
export interface SettingDefinition {
type: 'boolean' | 'string' | 'number' | 'array' | 'object';
label: string;
category: string;
requiresRestart: boolean;
default: boolean | string | number | string[] | object | undefined;
description?: string;
parentKey?: string;
childKey?: string;
key?: string;
properties?: SettingsSchema;
showInDialog?: boolean;
}
export interface SettingsSchema {
[key: string]: SettingDefinition;
}
export type MemoryImportFormat = 'tree' | 'flat';
export type DnsResolutionOrder = 'ipv4first' | 'verbatim';
/**
* The canonical schema for all settings.
* The structure of this object defines the structure of the `Settings` type.
* `as const` is crucial for TypeScript to infer the most specific types possible.
*/
export const SETTINGS_SCHEMA = {
// Maintained for compatibility/criticality
mcpServers: {
type: 'object',
label: 'MCP Servers',
category: 'Advanced',
requiresRestart: true,
default: {} as Record<string, MCPServerConfig>,
description: 'Configuration for MCP servers.',
showInDialog: false,
},
general: {
type: 'object',
label: 'General',
category: 'General',
requiresRestart: false,
default: {},
description: 'General application settings.',
showInDialog: false,
properties: {
preferredEditor: {
type: 'string',
label: 'Preferred Editor',
category: 'General',
requiresRestart: false,
default: undefined as string | undefined,
description: 'The preferred editor to open files in.',
showInDialog: false,
},
vimMode: {
type: 'boolean',
label: 'Vim Mode',
category: 'General',
requiresRestart: false,
default: false,
description: 'Enable Vim keybindings',
showInDialog: true,
},
disableAutoUpdate: {
type: 'boolean',
label: 'Disable Auto Update',
category: 'General',
requiresRestart: false,
default: false,
description: 'Disable automatic updates',
showInDialog: true,
},
disableUpdateNag: {
type: 'boolean',
label: 'Disable Update Nag',
category: 'General',
requiresRestart: false,
default: false,
description: 'Disable update notification prompts.',
showInDialog: false,
},
checkpointing: {
type: 'object',
label: 'Checkpointing',
category: 'General',
requiresRestart: true,
default: {},
description: 'Session checkpointing settings.',
showInDialog: false,
properties: {
enabled: {
type: 'boolean',
label: 'Enable Checkpointing',
category: 'General',
requiresRestart: true,
default: false,
description: 'Enable session checkpointing for recovery',
showInDialog: false,
},
},
},
enablePromptCompletion: {
type: 'boolean',
label: 'Enable Prompt Completion',
category: 'General',
requiresRestart: true,
default: false,
description:
'Enable AI-powered prompt completion suggestions while typing.',
showInDialog: true,
},
debugKeystrokeLogging: {
type: 'boolean',
label: 'Debug Keystroke Logging',
category: 'General',
requiresRestart: false,
default: false,
description: 'Enable debug logging of keystrokes to the console.',
showInDialog: true,
},
},
},
ui: {
type: 'object',
label: 'UI',
category: 'UI',
requiresRestart: false,
default: {},
description: 'User interface settings.',
showInDialog: false,
properties: {
theme: {
type: 'string',
label: 'Theme',
category: 'UI',
requiresRestart: false,
default: undefined as string | undefined,
description: 'The color theme for the UI.',
showInDialog: false,
},
customThemes: {
type: 'object',
label: 'Custom Themes',
category: 'UI',
requiresRestart: false,
default: {} as Record<string, CustomTheme>,
description: 'Custom theme definitions.',
showInDialog: false,
},
hideWindowTitle: {
type: 'boolean',
label: 'Hide Window Title',
category: 'UI',
requiresRestart: true,
default: false,
description: 'Hide the window title bar',
showInDialog: true,
},
hideTips: {
type: 'boolean',
label: 'Hide Tips',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Hide helpful tips in the UI',
showInDialog: true,
},
hideBanner: {
type: 'boolean',
label: 'Hide Banner',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Hide the application banner',
showInDialog: true,
},
hideFooter: {
type: 'boolean',
label: 'Hide Footer',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Hide the footer from the UI',
showInDialog: true,
},
showMemoryUsage: {
type: 'boolean',
label: 'Show Memory Usage',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Display memory usage information in the UI',
showInDialog: true,
},
showLineNumbers: {
type: 'boolean',
label: 'Show Line Numbers',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Show line numbers in the chat.',
showInDialog: true,
},
showCitations: {
type: 'boolean',
label: 'Show Citations',
category: 'UI',
requiresRestart: false,
default: false,
description: 'Show citations for generated text in the chat.',
showInDialog: true,
},
accessibility: {
type: 'object',
label: 'Accessibility',
category: 'UI',
requiresRestart: true,
default: {},
description: 'Accessibility settings.',
showInDialog: false,
properties: {
disableLoadingPhrases: {
type: 'boolean',
label: 'Disable Loading Phrases',
category: 'UI',
requiresRestart: true,
default: false,
description: 'Disable loading phrases for accessibility',
showInDialog: true,
},
screenReader: {
type: 'boolean',
label: 'Screen Reader Mode',
category: 'UI',
requiresRestart: true,
default: false,
description:
'Render output in plain-text to be more screen reader accessible',
showInDialog: true,
},
},
},
},
},
ide: {
type: 'object',
label: 'IDE',
category: 'IDE',
requiresRestart: true,
default: {},
description: 'IDE integration settings.',
showInDialog: false,
properties: {
enabled: {
type: 'boolean',
label: 'IDE Mode',
category: 'IDE',
requiresRestart: true,
default: false,
description: 'Enable IDE integration mode',
showInDialog: true,
},
hasSeenNudge: {
type: 'boolean',
label: 'Has Seen IDE Integration Nudge',
category: 'IDE',
requiresRestart: false,
default: false,
description: 'Whether the user has seen the IDE integration nudge.',
showInDialog: false,
},
},
},
privacy: {
type: 'object',
label: 'Privacy',
category: 'Privacy',
requiresRestart: true,
default: {},
description: 'Privacy-related settings.',
showInDialog: false,
properties: {
usageStatisticsEnabled: {
type: 'boolean',
label: 'Enable Usage Statistics',
category: 'Privacy',
requiresRestart: true,
default: true,
description: 'Enable collection of usage statistics',
showInDialog: false,
},
},
},
telemetry: {
type: 'object',
label: 'Telemetry',
category: 'Advanced',
requiresRestart: true,
default: undefined as TelemetrySettings | undefined,
description: 'Telemetry configuration.',
showInDialog: false,
},
model: {
type: 'object',
label: 'Model',
category: 'Model',
requiresRestart: false,
default: {},
description: 'Settings related to the generative model.',
showInDialog: false,
properties: {
name: {
type: 'string',
label: 'Model',
category: 'Model',
requiresRestart: false,
default: undefined as string | undefined,
description: 'The Gemini model to use for conversations.',
showInDialog: false,
},
maxSessionTurns: {
type: 'number',
label: 'Max Session Turns',
category: 'Model',
requiresRestart: false,
default: -1,
description:
'Maximum number of user/model/tool turns to keep in a session. -1 means unlimited.',
showInDialog: true,
},
summarizeToolOutput: {
type: 'object',
label: 'Summarize Tool Output',
category: 'Model',
requiresRestart: false,
default: undefined as
| Record<string, { tokenBudget?: number }>
| undefined,
description: 'Settings for summarizing tool output.',
showInDialog: false,
},
chatCompression: {
type: 'object',
label: 'Chat Compression',
category: 'Model',
requiresRestart: false,
default: undefined as ChatCompressionSettings | undefined,
description: 'Chat compression settings.',
showInDialog: false,
},
skipNextSpeakerCheck: {
type: 'boolean',
label: 'Skip Next Speaker Check',
category: 'Model',
requiresRestart: false,
default: false,
description: 'Skip the next speaker check.',
showInDialog: true,
},
},
},
context: {
type: 'object',
label: 'Context',
category: 'Context',
requiresRestart: false,
default: {},
description: 'Settings for managing context provided to the model.',
showInDialog: false,
properties: {
fileName: {
type: 'object',
label: 'Context File Name',
category: 'Context',
requiresRestart: false,
default: undefined as string | string[] | undefined,
description: 'The name of the context file.',
showInDialog: false,
},
importFormat: {
type: 'string',
label: 'Memory Import Format',
category: 'Context',
requiresRestart: false,
default: undefined as MemoryImportFormat | undefined,
description: 'The format to use when importing memory.',
showInDialog: false,
},
discoveryMaxDirs: {
type: 'number',
label: 'Memory Discovery Max Dirs',
category: 'Context',
requiresRestart: false,
default: 200,
description: 'Maximum number of directories to search for memory.',
showInDialog: true,
},
includeDirectories: {
type: 'array',
label: 'Include Directories',
category: 'Context',
requiresRestart: false,
default: [] as string[],
description:
'Additional directories to include in the workspace context. Missing directories will be skipped with a warning.',
showInDialog: false,
},
loadMemoryFromIncludeDirectories: {
type: 'boolean',
label: 'Load Memory From Include Directories',
category: 'Context',
requiresRestart: false,
default: false,
description: 'Whether to load memory files from include directories.',
showInDialog: true,
},
fileFiltering: {
type: 'object',
label: 'File Filtering',
category: 'Context',
requiresRestart: true,
default: {},
description: 'Settings for git-aware file filtering.',
showInDialog: false,
properties: {
respectGitIgnore: {
type: 'boolean',
label: 'Respect .gitignore',
category: 'Context',
requiresRestart: true,
default: true,
description: 'Respect .gitignore files when searching',
showInDialog: true,
},
respectGeminiIgnore: {
type: 'boolean',
label: 'Respect .geminiignore',
category: 'Context',
requiresRestart: true,
default: true,
description: 'Respect .geminiignore files when searching',
showInDialog: true,
},
enableRecursiveFileSearch: {
type: 'boolean',
label: 'Enable Recursive File Search',
category: 'Context',
requiresRestart: true,
default: true,
description: 'Enable recursive file search functionality',
showInDialog: true,
},
disableFuzzySearch: {
type: 'boolean',
label: 'Disable Fuzzy Search',
category: 'Context',
requiresRestart: true,
default: false,
description: 'Disable fuzzy search when searching for files.',
showInDialog: true,
},
},
},
},
},
tools: {
type: 'object',
label: 'Tools',
category: 'Tools',
requiresRestart: true,
default: {},
description: 'Settings for built-in and custom tools.',
showInDialog: false,
properties: {
sandbox: {
type: 'object',
label: 'Sandbox',
category: 'Tools',
requiresRestart: true,
default: undefined as boolean | string | undefined,
description:
'Sandbox execution environment (can be a boolean or a path string).',
showInDialog: false,
},
usePty: {
type: 'boolean',
label: 'Use node-pty for Shell Execution',
category: 'Tools',
requiresRestart: true,
default: false,
description:
'Use node-pty for shell command execution. Fallback to child_process still applies.',
showInDialog: true,
},
core: {
type: 'array',
label: 'Core Tools',
category: 'Tools',
requiresRestart: true,
default: undefined as string[] | undefined,
description: 'Paths to core tool definitions.',
showInDialog: false,
},
allowed: {
type: 'array',
label: 'Allowed Tools',
category: 'Advanced',
requiresRestart: true,
default: undefined as string[] | undefined,
description:
'A list of tool names that will bypass the confirmation dialog.',
showInDialog: false,
},
exclude: {
type: 'array',
label: 'Exclude Tools',
category: 'Tools',
requiresRestart: true,
default: undefined as string[] | undefined,
description: 'Tool names to exclude from discovery.',
showInDialog: false,
},
discoveryCommand: {
type: 'string',
label: 'Tool Discovery Command',
category: 'Tools',
requiresRestart: true,
default: undefined as string | undefined,
description: 'Command to run for tool discovery.',
showInDialog: false,
},
callCommand: {
type: 'string',
label: 'Tool Call Command',
category: 'Tools',
requiresRestart: true,
default: undefined as string | undefined,
description: 'Command to run for tool calls.',
showInDialog: false,
},
useRipgrep: {
type: 'boolean',
label: 'Use Ripgrep',
category: 'Tools',
requiresRestart: false,
default: false,
description:
'Use ripgrep for file content search instead of the fallback implementation. Provides faster search performance.',
showInDialog: true,
},
},
},
mcp: {
type: 'object',
label: 'MCP',
category: 'MCP',
requiresRestart: true,
default: {},
description: 'Settings for Model Context Protocol (MCP) servers.',
showInDialog: false,
properties: {
serverCommand: {
type: 'string',
label: 'MCP Server Command',
category: 'MCP',
requiresRestart: true,
default: undefined as string | undefined,
description: 'Command to start an MCP server.',
showInDialog: false,
},
allowed: {
type: 'array',
label: 'Allow MCP Servers',
category: 'MCP',
requiresRestart: true,
default: undefined as string[] | undefined,
description: 'A whitelist of MCP servers to allow.',
showInDialog: false,
},
excluded: {
type: 'array',
label: 'Exclude MCP Servers',
category: 'MCP',
requiresRestart: true,
default: undefined as string[] | undefined,
description: 'A blacklist of MCP servers to exclude.',
showInDialog: false,
},
},
},
useSmartEdit: {
type: 'boolean',
label: 'Use Smart Edit',
category: 'Advanced',
requiresRestart: false,
default: false,
description: 'Enable the smart-edit tool instead of the replace tool.',
showInDialog: false,
},
security: {
type: 'object',
label: 'Security',
category: 'Security',
requiresRestart: true,
default: {},
description: 'Security-related settings.',
showInDialog: false,
properties: {
folderTrust: {
type: 'object',
label: 'Folder Trust',
category: 'Security',
requiresRestart: false,
default: {},
description: 'Settings for folder trust.',
showInDialog: false,
properties: {
featureEnabled: {
type: 'boolean',
label: 'Folder Trust Feature',
category: 'Security',
requiresRestart: true,
default: false,
description: 'Enable folder trust feature for enhanced security.',
showInDialog: true,
},
enabled: {
type: 'boolean',
label: 'Folder Trust',
category: 'Security',
requiresRestart: true,
default: false,
description: 'Setting to track whether Folder trust is enabled.',
showInDialog: true,
},
},
},
auth: {
type: 'object',
label: 'Authentication',
category: 'Security',
requiresRestart: true,
default: {},
description: 'Authentication settings.',
showInDialog: false,
properties: {
selectedType: {
type: 'string',
label: 'Selected Auth Type',
category: 'Security',
requiresRestart: true,
default: undefined as AuthType | undefined,
description: 'The currently selected authentication type.',
showInDialog: false,
},
useExternal: {
type: 'boolean',
label: 'Use External Auth',
category: 'Security',
requiresRestart: true,
default: undefined as boolean | undefined,
description: 'Whether to use an external authentication flow.',
showInDialog: false,
},
},
},
},
},
advanced: {
type: 'object',
label: 'Advanced',
category: 'Advanced',
requiresRestart: true,
default: {},
description: 'Advanced settings for power users.',
showInDialog: false,
properties: {
autoConfigureMemory: {
type: 'boolean',
label: 'Auto Configure Max Old Space Size',
category: 'Advanced',
requiresRestart: true,
default: false,
description: 'Automatically configure Node.js memory limits',
showInDialog: false,
},
dnsResolutionOrder: {
type: 'string',
label: 'DNS Resolution Order',
category: 'Advanced',
requiresRestart: true,
default: undefined as DnsResolutionOrder | undefined,
description: 'The DNS resolution order.',
showInDialog: false,
},
excludedEnvVars: {
type: 'array',
label: 'Excluded Project Environment Variables',
category: 'Advanced',
requiresRestart: false,
default: ['DEBUG', 'DEBUG_MODE'] as string[],
description: 'Environment variables to exclude from project context.',
showInDialog: false,
},
bugCommand: {
type: 'object',
label: 'Bug Command',
category: 'Advanced',
requiresRestart: false,
default: undefined as BugCommandSettings | undefined,
description: 'Configuration for the bug report command.',
showInDialog: false,
},
},
},
experimental: {
type: 'object',
label: 'Experimental',
category: 'Experimental',
requiresRestart: true,
default: {},
description: 'Setting to enable experimental features',
showInDialog: false,
properties: {
extensionManagement: {
type: 'boolean',
label: 'Extension Management',
category: 'Experimental',
requiresRestart: true,
default: false,
description: 'Enable extension management features.',
showInDialog: false,
},
},
},
extensions: {
type: 'object',
label: 'Extensions',
category: 'Extensions',
requiresRestart: true,
default: {},
description: 'Settings for extensions.',
showInDialog: false,
properties: {
disabled: {
type: 'array',
label: 'Disabled Extensions',
category: 'Extensions',
requiresRestart: true,
default: [] as string[],
description: 'List of disabled extensions.',
showInDialog: false,
},
workspacesWithMigrationNudge: {
type: 'array',
label: 'Workspaces with Migration Nudge',
category: 'Extensions',
requiresRestart: false,
default: [] as string[],
description:
'List of workspaces for which the migration nudge has been shown.',
showInDialog: false,
},
},
},
} as const;
type InferSettings<T extends SettingsSchema> = {
-readonly [K in keyof T]?: T[K] extends { properties: SettingsSchema }
? InferSettings<T[K]['properties']>
: T[K]['default'] extends boolean
? boolean
: T[K]['default'];
};
export type Settings = InferSettings<typeof SETTINGS_SCHEMA>;
|