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

@@ -51,11 +51,12 @@ 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.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 |

View File

@@ -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,
},

View File

@@ -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',

View File

@@ -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;

View File

@@ -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;
}
}