Files
openidea/crates/ide-core/src/workflow_settings.rs
T
l0ng-ai 6ab7627fc4 feat(vcs): project conventions for Generate Commit Message with Agent (#4014)
Settings › Version Control › Commit gets a Commit Message Generation section with a multi-line field (vcs.commit.agentInstructions, global or per project). Its text is added to the agent's prompt as the conventions to follow, ahead of the style taken from recent commit subjects.

Closes #3934
2026-11-17 21:53:38 +08:00

540 lines
19 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Settings of IDEA's Version Control, Build, Execution, Deployment and Tools
//! groups. The fields hang off `Settings` in `settings.rs`.
use serde::{Deserialize, Serialize};
use specta::Type;
use std::collections::BTreeMap;
/// Version Control (main page) and its sub-pages.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct VcsSettings {
/// Colour folders that contain changed files (project tree, tabs).
pub show_dirty_directories: bool,
/// Stop file history (Show History) after `history_limit` commits.
pub limit_history: bool,
pub history_limit: u32,
pub git: GitSettings,
pub commit: CommitSettings,
pub confirmation: VcsConfirmationSettings,
pub shelf: ShelfSettings,
/// Issue Navigation: commit-message patterns turned into links.
pub issue_navigation: Vec<IssueLink>,
}
impl Default for VcsSettings {
fn default() -> Self {
Self {
// IDEA's VcsConfiguration.SHOW_DIRTY_RECURSIVELY is off by default.
show_dirty_directories: false,
limit_history: true,
history_limit: 1000,
git: GitSettings::default(),
commit: CommitSettings::default(),
confirmation: VcsConfirmationSettings::default(),
shelf: ShelfSettings::default(),
issue_navigation: Vec::new(),
}
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct GitSettings {
/// Show blame after the current editor line.
pub inline_blame: bool,
/// A click (or Enter / Space) on the inline blame label opens its commit; off, the
/// label is plain text and a click on it places the caret as past the line end.
pub inline_blame_clickable: bool,
pub show_branch_in_project_view: bool,
/// Path to the git executable; empty = auto-detect.
pub executable: String,
/// Default of Update Project: `merge` | `rebase`.
pub update_method: String,
/// Push rejected (non-fast-forward): update the branch and push again.
pub auto_update_on_push_rejected: bool,
pub warn_crlf: bool,
pub warn_detached_head: bool,
/// Background check for incoming commits: `auto` | `always` | `never`.
pub incoming_check: String,
/// Minutes between background checks for incoming commits.
pub incoming_check_interval: u32,
/// Branch name globs, `;`/`,`-separated; force push to them is prohibited.
pub protected_branches: String,
/// Initial state of Commit Options › Sign-off Commit.
pub sign_off: bool,
/// Ask before committing files larger than `large_file_mb`.
pub warn_large_files: bool,
pub large_file_mb: u32,
/// Ask before committing names that are invalid on Windows or differ only in case.
pub warn_bad_file_names: bool,
/// Commit and Push opens the Push dialog; otherwise it pushes right away.
pub show_push_dialog: bool,
/// With `show_push_dialog`: only for commits to protected branches.
pub push_dialog_only_protected: bool,
/// Stashes and shelves share one tab.
pub combine_stash_and_shelf: bool,
/// The non-modal Commit tool window works on the index: Staged / Unstaged groups,
/// stage and unstage instead of inclusion checkboxes, and no change lists.
pub staging_area: bool,
}
impl Default for GitSettings {
fn default() -> Self {
Self {
inline_blame: false,
inline_blame_clickable: true,
show_branch_in_project_view: false,
executable: String::new(),
update_method: "merge".into(),
auto_update_on_push_rejected: false,
warn_crlf: true,
warn_detached_head: true,
incoming_check: "auto".into(),
incoming_check_interval: 15,
protected_branches: "master; main".into(),
sign_off: false,
warn_large_files: true,
large_file_mb: 50,
warn_bad_file_names: true,
show_push_dialog: true,
push_dialog_only_protected: false,
combine_stash_and_shelf: false,
staging_area: false,
}
}
}
/// Version Control › Commit: commit checks and commit-message inspections.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct CommitSettings {
/// Commit from the Commit tool window; off = Local Changes in the Git tool
/// window and a Commit dialog.
pub non_modal: bool,
/// Start with an empty message instead of the last one / the changelist's.
pub clear_initial_message: bool,
pub analyze_code: bool,
pub check_todo: bool,
pub reformat: bool,
pub optimize_imports: bool,
pub cleanup: bool,
pub blank_line_after_subject: bool,
pub limit_subject: bool,
pub subject_limit: u32,
pub limit_body: bool,
pub body_limit: u32,
pub show_right_margin: bool,
pub wrap_at_margin: bool,
/// Plugin before-commit checks turned off (`<plugin id>/<check id>`); the rest run.
pub disabled_plugin_checks: Vec<String>,
/// Double-click / Enter in the changes view: `None` follows the interface (the
/// Commit tool window opens the diff, Local Changes the source file).
///
/// No `skip_serializing_if`: an unset value must still appear in
/// `Settings::default()`, or `SettingsStore::set` rejects the key as unknown.
#[specta(optional)]
pub double_click_opens_diff: Option<bool>,
/// Team conventions for Generate Commit Message with Agent, added to its prompt.
pub agent_instructions: String,
}
impl Default for CommitSettings {
fn default() -> Self {
Self {
non_modal: true,
clear_initial_message: false,
analyze_code: true,
check_todo: true,
reformat: false,
optimize_imports: false,
cleanup: false,
blank_line_after_subject: true,
limit_subject: true,
subject_limit: 72,
limit_body: false,
body_limit: 72,
show_right_margin: true,
wrap_at_margin: false,
disabled_plugin_checks: Vec::new(),
double_click_opens_diff: None,
agent_instructions: String::new(),
}
}
}
/// Version Control › Confirmation.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct VcsConfirmationSettings {
/// `ask` | `silently` | `never`.
pub on_create: String,
pub on_delete: String,
/// Update Project opens its options dialog first.
pub show_update_options: bool,
pub confirm_drop_commits: bool,
/// After a patch is saved: `ask` | `no` | `reveal` (show it in the file manager).
pub on_patch_created: String,
}
impl Default for VcsConfirmationSettings {
fn default() -> Self {
Self {
on_create: "ask".into(),
on_delete: "ask".into(),
show_update_options: true,
confirm_drop_commits: true,
on_patch_created: "ask".into(),
}
}
}
/// Tools › Diff & Merge › External Diff Tools: a program that shows two files' differences.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct ExternalDiffSettings {
/// Offer Show Diff in External Tool in diff viewers.
pub enabled: bool,
/// The program to start.
pub path: String,
/// Its arguments: `%1` the left file, `%2` the right file, `%3` the diff's title.
pub parameters: String,
}
impl Default for ExternalDiffSettings {
fn default() -> Self {
Self { enabled: false, path: String::new(), parameters: "%1 %2 %3".into() }
}
}
/// Version Control › Shelf.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct ShelfSettings {
/// Initial state of Unshelve's "Remove successfully applied files from the shelf".
pub remove_applied: bool,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct IssueLink {
/// Regular expression matched in commit messages.
pub pattern: String,
/// Link with `$0` (whole match) / `$1`… (groups) placeholders.
pub link: String,
}
/// Per-level colours for console log lines: a line whose level is detected
/// (`ERROR`, `WARN`, …) takes the level's colour; ANSI colours the program
/// prints itself win over it. Values are CSS colours, usually scheme tokens.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct LogLevelColors {
pub enabled: bool,
pub error: String,
pub warn: String,
pub info: String,
pub debug: String,
pub trace: String,
}
impl Default for LogLevelColors {
fn default() -> Self {
Self {
enabled: false,
error: "var(--ansi-red)".into(),
warn: "var(--ansi-yellow)".into(),
info: "var(--ansi-green)".into(),
debug: "var(--ansi-cyan)".into(),
trace: "var(--ansi-magenta)".into(),
}
}
}
/// Database settings: Query Execution and SQL Resolution Scopes.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct DatabaseSettings {
/// A console's result sets show under the statements that produced them, in the editor,
/// instead of in the Services view's result tabs.
pub in_editor_results: bool,
/// Languages & Frameworks › SQL Resolution Scopes: the data source SQL in a file or folder
/// resolves against (completion, inspections, navigation), most specific path first.
pub resolution_scopes: Vec<SqlResolutionScope>,
}
/// One row of SQL Resolution Scopes.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct SqlResolutionScope {
/// Project-relative file or folder, `/`-separated; empty for the whole project.
pub path: String,
/// Data source id.
pub data_source: String,
/// Schema unqualified names resolve in; empty for the data source's default.
pub schema: String,
}
/// Build, Execution, Deployment › Console.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct ConsoleSettings {
pub soft_wrap: bool,
pub override_buffer: bool,
pub buffer_kb: u32,
/// Encoding of process output (`UTF-8`, `windows-1252`, `GBK`…).
pub encoding: String,
/// Consecutive lines containing any of these are folded.
pub fold_patterns: Vec<String>,
/// Log lines take the colour of their level (Run/Debug consoles).
pub log_colors: LogLevelColors,
}
impl Default for ConsoleSettings {
fn default() -> Self {
Self {
soft_wrap: false,
override_buffer: true,
buffer_kb: 1024,
encoding: "UTF-8".into(),
fold_patterns: vec![
"at java.base/jdk.internal.reflect.".into(),
"at java.base/java.lang.reflect.Method.invoke".into(),
"at org.junit.".into(),
"at node:internal/".into(),
"<frozen importlib._bootstrap".into(),
],
log_colors: LogLevelColors::default(),
}
}
}
/// Build, Execution, Deployment › Debugger (+ Data Views, Stepping, Python Debugger).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct DebuggerSettings {
pub show_on_breakpoint: bool,
pub focus_app_on_breakpoint: bool,
pub hide_on_termination: bool,
/// A breakpoint or exception hit brings the Debug tool window's Threads & Variables tab to the front.
pub variables_on_breakpoint: bool,
pub breakpoints_any_file: bool,
/// While suspended, hovering the start of a line shows a Run to Cursor button.
pub run_to_cursor_inlay: bool,
pub inline_values: bool,
/// Data Views: list variables by name instead of the adapter's order.
pub sort_values: bool,
/// Data Views: evaluate watches while the program runs, where the debugger can (JavaScript).
pub live_watches: bool,
pub value_tooltip: bool,
/// While suspended, selecting an expression shows its value.
pub value_tooltip_on_selection: bool,
pub value_tooltip_delay: u32,
/// Stepping: do not step into library code (debugpy `justMyCode`, js-debug `skipFiles`).
pub skip_library_code: bool,
/// JavaScript: debugging a dev server (`vite`, `next dev`) also opens its page in a browser session.
pub debug_server_page: bool,
pub python: PythonDebuggerSettings,
}
impl Default for DebuggerSettings {
fn default() -> Self {
Self {
show_on_breakpoint: true,
focus_app_on_breakpoint: false,
hide_on_termination: false,
variables_on_breakpoint: true,
breakpoints_any_file: false,
run_to_cursor_inlay: true,
inline_values: true,
sort_values: false,
live_watches: false,
value_tooltip: true,
value_tooltip_on_selection: true,
value_tooltip_delay: 700,
skip_library_code: true,
debug_server_page: false,
python: PythonDebuggerSettings::default(),
}
}
}
/// Python Debugger (debugpy launch options).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct PythonDebuggerSettings {
pub attach_subprocess: bool,
pub gevent: bool,
}
impl Default for PythonDebuggerSettings {
fn default() -> Self {
Self { attach_subprocess: true, gevent: false }
}
}
/// Run/Debug configuration behaviour.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct RunSettings {
/// Target for configurations without an explicit target. Empty = local.
pub default_target: String,
pub confirm_rerun: bool,
/// Ask before closing a Run tab whose process is still running.
pub confirm_terminate: bool,
pub show_on_start: bool,
/// New Run/Debug tabs start pinned: a later run doesn't take their place once finished.
pub pin_tabs: bool,
/// Grace period between interrupt and kill when stopping a process.
pub termination_timeout_ms: u32,
}
impl Default for RunSettings {
fn default() -> Self {
Self {
default_target: String::new(),
confirm_rerun: true,
confirm_terminate: true,
show_on_start: true,
pin_tabs: false,
termination_timeout_ms: 3000,
}
}
}
/// Tools › Terminal.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct TerminalSettings {
/// Empty = project root; relative paths resolve against it.
pub start_directory: String,
pub env: BTreeMap<String, String>,
/// Shell command line; empty = the login shell.
pub shell_path: String,
pub tab_name: String,
pub audible_bell: bool,
pub close_on_exit: bool,
pub mouse_reporting: bool,
pub copy_on_selection: bool,
pub paste_on_middle_click: bool,
pub override_ide_shortcuts: bool,
pub shell_integration: bool,
pub highlight_hyperlinks: bool,
pub highlight_selection: bool,
pub option_as_meta: bool,
/// Escape moves focus to the editor instead of reaching the shell.
pub escape_to_editor: bool,
/// `block` | `underline` | `bar`.
pub cursor_shape: String,
pub cursor_blink: bool,
pub use_editor_font: bool,
pub font_family: String,
pub font_size: f32,
/// Multiple of the cell height.
pub line_height: f32,
/// Font tried for glyphs the main font lacks; empty = none.
pub fallback_font_family: String,
/// Multiple of the cell width.
pub column_width: f32,
}
impl Default for TerminalSettings {
fn default() -> Self {
Self {
start_directory: String::new(),
env: BTreeMap::new(),
shell_path: String::new(),
tab_name: "Local".into(),
audible_bell: true,
close_on_exit: true,
mouse_reporting: true,
copy_on_selection: false,
paste_on_middle_click: true,
override_ide_shortcuts: true,
shell_integration: true,
highlight_hyperlinks: true,
highlight_selection: true,
option_as_meta: false,
escape_to_editor: false,
cursor_shape: "block".into(),
cursor_blink: true,
use_editor_font: true,
font_family: "JetBrains Mono".into(),
font_size: 13.0,
line_height: 1.0,
fallback_font_family: String::new(),
column_width: 1.0,
}
}
}
/// Tools › Actions on Save (Reformat code is `editor.formatOnSave`).
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct ActionsOnSaveSettings {
pub optimize_imports: bool,
/// Run code cleanup (`source.fixAll`).
pub cleanup: bool,
}
/// Tools › External Tools entry.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct ExternalTool {
pub id: String,
pub name: String,
pub description: String,
pub group: String,
pub enabled: bool,
pub program: String,
/// Arguments with macros (`$FilePath$`, `$ProjectFileDir$`…), shell-quoted.
pub arguments: String,
pub working_directory: String,
pub synchronize_after: bool,
pub open_console: bool,
}
impl Default for ExternalTool {
fn default() -> Self {
Self {
id: String::new(),
name: String::new(),
description: String::new(),
group: "External Tools".into(),
enabled: true,
program: String::new(),
arguments: String::new(),
working_directory: "$ProjectFileDir$".into(),
synchronize_after: true,
open_console: true,
}
}
}
/// Tools › Agents: Command Execution Policy (whitelist and blacklist patterns).
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
#[serde(default, rename_all = "camelCase")]
pub struct AgentSecuritySettings {
/// Commands or patterns (`git status*`, `pwd`) automatically approved without prompting.
pub allowed_commands: Vec<String>,
/// Commands or patterns (`rm -rf *`, `mkfs*`) automatically rejected.
pub blocked_commands: Vec<String>,
}
impl Default for AgentSecuritySettings {
fn default() -> Self {
Self {
allowed_commands: Vec::new(),
blocked_commands: vec![
"rm -rf *".into(),
"rm -rf /".into(),
"mkfs*".into(),
"dd *".into(),
":(){ :|:& };:".into(),
"shutdown*".into(),
"reboot*".into(),
],
}
}
}