From 61e378644e1b5c835c6d93c75cb0bfe792928ea9 Mon Sep 17 00:00:00 2001 From: tanzhenxin Date: Tue, 16 Dec 2025 15:02:59 +0800 Subject: [PATCH] feat: update configuration and shell tool implementations Co-authored-by: Qwen-Coder --- docs/users/configuration/settings.md | 23 +++------ packages/cli/src/config/config.ts | 2 +- packages/cli/src/config/settingsSchema.ts | 62 ++++------------------- packages/core/src/config/config.ts | 8 +-- packages/core/src/tools/shell.ts | 21 ++------ 5 files changed, 27 insertions(+), 89 deletions(-) diff --git a/docs/users/configuration/settings.md b/docs/users/configuration/settings.md index de710d27..9fecc6d3 100644 --- a/docs/users/configuration/settings.md +++ b/docs/users/configuration/settings.md @@ -50,13 +50,14 @@ Settings are organized into categories. All settings should be placed within the #### general -| Setting | Type | Description | Default | -| ------------------------------- | ------- | ------------------------------------------ | ----------- | -| `general.preferredEditor` | string | The preferred editor to open files in. | `undefined` | -| `general.vimMode` | boolean | Enable Vim keybindings. | `false` | -| `general.disableAutoUpdate` | boolean | Disable automatic updates. | `false` | -| `general.disableUpdateNag` | boolean | Disable update notification prompts. | `false` | -| `general.checkpointing.enabled` | boolean | Enable session checkpointing for recovery. | `false` | +| Setting | Type | Description | Default | +| ------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- | ----------- | +| `general.preferredEditor` | string | The preferred editor to open files in. | `undefined` | +| `general.vimMode` | boolean | Enable Vim keybindings. | `false` | +| `general.disableAutoUpdate` | boolean | Disable automatic updates. | `false` | +| `general.disableUpdateNag` | boolean | Disable update notification prompts. | `false` | +| `general.gitCoAuthor` | boolean | Automatically add a Co-authored-by trailer to git commit messages when commits are made through Qwen Code. | `true` | +| `general.checkpointing.enabled` | boolean | Enable session checkpointing for recovery. | `false` | #### output @@ -175,14 +176,6 @@ If you are experiencing performance issues with file searching (e.g., with `@` c | `tools.truncateToolOutputLines` | number | Maximum lines or entries kept when truncating tool output. Applies to Shell, Grep, Glob, ReadFile and ReadManyFiles tools. | `1000` | Requires restart: Yes | | `tools.autoAccept` | boolean | Controls whether the CLI automatically accepts and executes tool calls that are considered safe (e.g., read-only operations) without explicit user confirmation. If set to `true`, the CLI will bypass the confirmation prompt for tools deemed safe. | `false` | | -#### git - -| Setting | Type | Description | Default | -| ------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------- | -| `git.gitCoAuthor.enabled` | boolean | Automatically add a Co-authored-by trailer to git commit messages when commits are made through Qwen Code. | `true` | -| `git.gitCoAuthor.name` | string | The name to use in the Co-authored-by trailer. | `"Qwen-Coder"` | -| `git.gitCoAuthor.email` | string | The email to use in the Co-authored-by trailer. | `"qwen-coder@alibabacloud.com"` | - #### mcp | Setting | Type | Description | Default | diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index 16915558..07ac1967 100755 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -1002,7 +1002,7 @@ export async function loadCliConfig( enableToolOutputTruncation: settings.tools?.enableToolOutputTruncation, eventEmitter: appEvents, useSmartEdit: argv.useSmartEdit ?? settings.useSmartEdit, - gitCoAuthor: settings.git?.gitCoAuthor, + gitCoAuthor: settings.general?.gitCoAuthor, output: { format: outputSettingsFormat, }, diff --git a/packages/cli/src/config/settingsSchema.ts b/packages/cli/src/config/settingsSchema.ts index e3a792b3..d653d85b 100644 --- a/packages/cli/src/config/settingsSchema.ts +++ b/packages/cli/src/config/settingsSchema.ts @@ -147,6 +147,16 @@ const SETTINGS_SCHEMA = { description: 'Disable update notification prompts.', showInDialog: false, }, + gitCoAuthor: { + type: 'boolean', + label: 'Git Co-Author', + category: 'General', + requiresRestart: false, + default: true, + description: + 'Automatically add a Co-authored-by trailer to git commit messages when commits are made through Qwen Code.', + showInDialog: false, + }, checkpointing: { type: 'object', label: 'Checkpointing', @@ -943,58 +953,6 @@ const SETTINGS_SCHEMA = { }, }, - git: { - type: 'object', - label: 'Git', - category: 'Git', - requiresRestart: false, - default: {}, - description: 'Git-related settings.', - showInDialog: false, - properties: { - gitCoAuthor: { - type: 'object', - label: 'Git Co-Author', - category: 'Git', - requiresRestart: false, - default: {}, - description: - 'Settings for automatic Co-authored-by trailer in git commits.', - showInDialog: false, - properties: { - enabled: { - type: 'boolean', - label: 'Enable Git Co-Author', - category: 'Git', - requiresRestart: false, - default: true, - description: - 'Automatically add Co-authored-by trailer to git commit messages.', - showInDialog: true, - }, - name: { - type: 'string', - label: 'Co-Author Name', - category: 'Git', - requiresRestart: false, - default: 'Qwen-Coder' as string | undefined, - description: 'The name to use in the Co-authored-by trailer.', - showInDialog: true, - }, - email: { - type: 'string', - label: 'Co-Author Email', - category: 'Git', - requiresRestart: false, - default: 'qwen-coder@alibabacloud.com' as string | undefined, - description: 'The email to use in the Co-authored-by trailer.', - showInDialog: true, - }, - }, - }, - }, - }, - mcp: { type: 'object', label: 'MCP', diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index d3c9b14a..d5b7f4be 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -287,7 +287,7 @@ export interface ConfigParameters { contextFileName?: string | string[]; accessibility?: AccessibilitySettings; telemetry?: TelemetrySettings; - gitCoAuthor?: GitCoAuthorSettings; + gitCoAuthor?: boolean; usageStatisticsEnabled?: boolean; fileFiltering?: { respectGitIgnore?: boolean; @@ -534,9 +534,9 @@ export class Config { useCollector: params.telemetry?.useCollector, }; this.gitCoAuthor = { - enabled: params.gitCoAuthor?.enabled ?? true, - name: params.gitCoAuthor?.name ?? 'Qwen-Coder', - email: params.gitCoAuthor?.email ?? 'qwen-coder@alibabacloud.com', + enabled: params.gitCoAuthor ?? true, + name: 'Qwen-Coder', + email: 'qwen-coder@alibabacloud.com', }; this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true; diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index 1a32e6b1..5354f925 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -335,23 +335,13 @@ export class ShellToolInvocation extends BaseToolInvocation< // Check if co-author feature is enabled const gitCoAuthorSettings = this.config.getGitCoAuthor(); - // Debug logging for gitCoAuthor feature - // TODO: Remove after debugging is complete - console.error( - '[gitCoAuthor] Settings:', - JSON.stringify(gitCoAuthorSettings), - ); - console.error('[gitCoAuthor] Command:', command); - if (!gitCoAuthorSettings.enabled) { - console.error('[gitCoAuthor] Feature disabled, skipping'); return command; } // Check if this is a git commit command (anywhere in the command, e.g., after "cd /path &&") const gitCommitPattern = /\bgit\s+commit\b/; if (!gitCommitPattern.test(command)) { - console.error('[gitCoAuthor] Not a git commit command, skipping'); return command; } @@ -372,24 +362,21 @@ Co-authored-by: ${gitCoAuthorSettings.name} <${gitCoAuthorSettings.email}>`; // (?:...|...)* matches normal chars or escapes, repeated const doubleQuotePattern = /(-[a-zA-Z]*m\s+)"((?:[^"\\]|\\.)*)"/; const singleQuotePattern = /(-[a-zA-Z]*m\s+)'((?:[^'\\]|\\.)*)'/; - const match = - command.match(doubleQuotePattern) || command.match(singleQuotePattern); - const quote = command.match(doubleQuotePattern) ? '"' : "'"; - - console.error('[gitCoAuthor] Message pattern match:', match ? 'YES' : 'NO'); + const doubleMatch = command.match(doubleQuotePattern); + const singleMatch = command.match(singleQuotePattern); + const match = doubleMatch ?? singleMatch; + const quote = doubleMatch ? '"' : "'"; if (match) { const [fullMatch, prefix, existingMessage] = match; const newMessage = existingMessage + coAuthor; const replacement = prefix + quote + newMessage + quote; - console.error('[gitCoAuthor] Adding co-author trailer'); return command.replace(fullMatch, replacement); } // If no -m flag found, the command might open an editor // In this case, we can't easily modify it, so return as-is - console.error('[gitCoAuthor] No -m flag found, skipping'); return command; } }