feat: update configuration and shell tool implementations

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin
2025-12-16 15:02:59 +08:00
parent fc58291c5c
commit 61e378644e
5 changed files with 27 additions and 89 deletions

View File

@@ -50,13 +50,14 @@ Settings are organized into categories. All settings should be placed within the
#### general #### general
| Setting | Type | Description | Default | | Setting | Type | Description | Default |
| ------------------------------- | ------- | ------------------------------------------ | ----------- | | ------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- | ----------- |
| `general.preferredEditor` | string | The preferred editor to open files in. | `undefined` | | `general.preferredEditor` | string | The preferred editor to open files in. | `undefined` |
| `general.vimMode` | boolean | Enable Vim keybindings. | `false` | | `general.vimMode` | boolean | Enable Vim keybindings. | `false` |
| `general.disableAutoUpdate` | boolean | Disable automatic updates. | `false` | | `general.disableAutoUpdate` | boolean | Disable automatic updates. | `false` |
| `general.disableUpdateNag` | boolean | Disable update notification prompts. | `false` | | `general.disableUpdateNag` | boolean | Disable update notification prompts. | `false` |
| `general.checkpointing.enabled` | boolean | Enable session checkpointing for recovery. | `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 #### 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.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` | | | `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 #### mcp
| Setting | Type | Description | Default | | Setting | Type | Description | Default |

View File

@@ -1002,7 +1002,7 @@ export async function loadCliConfig(
enableToolOutputTruncation: settings.tools?.enableToolOutputTruncation, enableToolOutputTruncation: settings.tools?.enableToolOutputTruncation,
eventEmitter: appEvents, eventEmitter: appEvents,
useSmartEdit: argv.useSmartEdit ?? settings.useSmartEdit, useSmartEdit: argv.useSmartEdit ?? settings.useSmartEdit,
gitCoAuthor: settings.git?.gitCoAuthor, gitCoAuthor: settings.general?.gitCoAuthor,
output: { output: {
format: outputSettingsFormat, format: outputSettingsFormat,
}, },

View File

@@ -147,6 +147,16 @@ const SETTINGS_SCHEMA = {
description: 'Disable update notification prompts.', description: 'Disable update notification prompts.',
showInDialog: false, 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: { checkpointing: {
type: 'object', type: 'object',
label: 'Checkpointing', 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: { mcp: {
type: 'object', type: 'object',
label: 'MCP', label: 'MCP',

View File

@@ -287,7 +287,7 @@ export interface ConfigParameters {
contextFileName?: string | string[]; contextFileName?: string | string[];
accessibility?: AccessibilitySettings; accessibility?: AccessibilitySettings;
telemetry?: TelemetrySettings; telemetry?: TelemetrySettings;
gitCoAuthor?: GitCoAuthorSettings; gitCoAuthor?: boolean;
usageStatisticsEnabled?: boolean; usageStatisticsEnabled?: boolean;
fileFiltering?: { fileFiltering?: {
respectGitIgnore?: boolean; respectGitIgnore?: boolean;
@@ -534,9 +534,9 @@ export class Config {
useCollector: params.telemetry?.useCollector, useCollector: params.telemetry?.useCollector,
}; };
this.gitCoAuthor = { this.gitCoAuthor = {
enabled: params.gitCoAuthor?.enabled ?? true, enabled: params.gitCoAuthor ?? true,
name: params.gitCoAuthor?.name ?? 'Qwen-Coder', name: 'Qwen-Coder',
email: params.gitCoAuthor?.email ?? 'qwen-coder@alibabacloud.com', email: 'qwen-coder@alibabacloud.com',
}; };
this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true; this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true;

View File

@@ -335,23 +335,13 @@ export class ShellToolInvocation extends BaseToolInvocation<
// Check if co-author feature is enabled // Check if co-author feature is enabled
const gitCoAuthorSettings = this.config.getGitCoAuthor(); 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) { if (!gitCoAuthorSettings.enabled) {
console.error('[gitCoAuthor] Feature disabled, skipping');
return command; return command;
} }
// Check if this is a git commit command (anywhere in the command, e.g., after "cd /path &&") // Check if this is a git commit command (anywhere in the command, e.g., after "cd /path &&")
const gitCommitPattern = /\bgit\s+commit\b/; const gitCommitPattern = /\bgit\s+commit\b/;
if (!gitCommitPattern.test(command)) { if (!gitCommitPattern.test(command)) {
console.error('[gitCoAuthor] Not a git commit command, skipping');
return command; return command;
} }
@@ -372,24 +362,21 @@ Co-authored-by: ${gitCoAuthorSettings.name} <${gitCoAuthorSettings.email}>`;
// (?:...|...)* matches normal chars or escapes, repeated // (?:...|...)* matches normal chars or escapes, repeated
const doubleQuotePattern = /(-[a-zA-Z]*m\s+)"((?:[^"\\]|\\.)*)"/; const doubleQuotePattern = /(-[a-zA-Z]*m\s+)"((?:[^"\\]|\\.)*)"/;
const singleQuotePattern = /(-[a-zA-Z]*m\s+)'((?:[^'\\]|\\.)*)'/; const singleQuotePattern = /(-[a-zA-Z]*m\s+)'((?:[^'\\]|\\.)*)'/;
const match = const doubleMatch = command.match(doubleQuotePattern);
command.match(doubleQuotePattern) || command.match(singleQuotePattern); const singleMatch = command.match(singleQuotePattern);
const quote = command.match(doubleQuotePattern) ? '"' : "'"; const match = doubleMatch ?? singleMatch;
const quote = doubleMatch ? '"' : "'";
console.error('[gitCoAuthor] Message pattern match:', match ? 'YES' : 'NO');
if (match) { if (match) {
const [fullMatch, prefix, existingMessage] = match; const [fullMatch, prefix, existingMessage] = match;
const newMessage = existingMessage + coAuthor; const newMessage = existingMessage + coAuthor;
const replacement = prefix + quote + newMessage + quote; const replacement = prefix + quote + newMessage + quote;
console.error('[gitCoAuthor] Adding co-author trailer');
return command.replace(fullMatch, replacement); return command.replace(fullMatch, replacement);
} }
// If no -m flag found, the command might open an editor // If no -m flag found, the command might open an editor
// In this case, we can't easily modify it, so return as-is // In this case, we can't easily modify it, so return as-is
console.error('[gitCoAuthor] No -m flag found, skipping');
return command; return command;
} }
} }