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

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