mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
Merge branch 'main' into feature/support-agents-directory-skills
This commit is contained in:
commit
6f362a89ae
304 changed files with 17148 additions and 9229 deletions
|
|
@ -248,6 +248,26 @@ describe('Server Config (config.ts)', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should store a system prompt override', () => {
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
systemPrompt: 'You are a custom system prompt.',
|
||||
});
|
||||
|
||||
expect(config.getSystemPrompt()).toBe('You are a custom system prompt.');
|
||||
expect(config.getAppendSystemPrompt()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should store an appended system prompt', () => {
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
appendSystemPrompt: 'Be extra concise.',
|
||||
});
|
||||
|
||||
expect(config.getAppendSystemPrompt()).toBe('Be extra concise.');
|
||||
expect(config.getSystemPrompt()).toBeUndefined();
|
||||
});
|
||||
|
||||
describe('initialize', () => {
|
||||
it('should throw an error if checkpointing is enabled and GitService fails', async () => {
|
||||
const gitError = new Error('Git is not installed');
|
||||
|
|
@ -1047,10 +1067,10 @@ describe('Server Config (config.ts)', () => {
|
|||
expect(config.getTruncateToolOutputThreshold()).toBe(50000);
|
||||
});
|
||||
|
||||
it('should return infinity when truncation is disabled', () => {
|
||||
it('should return infinity when threshold is zero or negative', () => {
|
||||
const customParams = {
|
||||
...baseParams,
|
||||
enableToolOutputTruncation: false,
|
||||
truncateToolOutputThreshold: 0,
|
||||
};
|
||||
const config = new Config(customParams);
|
||||
expect(config.getTruncateToolOutputThreshold()).toBe(
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ import {
|
|||
type FileSystemService,
|
||||
StandardFileSystemService,
|
||||
type FileEncodingType,
|
||||
FileEncoding,
|
||||
} from '../services/fileSystemService.js';
|
||||
import { GitService } from '../services/gitService.js';
|
||||
|
||||
// Tools
|
||||
import { AskUserQuestionTool } from '../tools/askUserQuestion.js';
|
||||
import { EditTool } from '../tools/edit.js';
|
||||
import { ExitPlanModeTool } from '../tools/exitPlanMode.js';
|
||||
import { GlobTool } from '../tools/glob.js';
|
||||
|
|
@ -95,6 +95,7 @@ import {
|
|||
// Utils
|
||||
import { shouldAttemptBrowserLaunch } from '../utils/browser.js';
|
||||
import { FileExclusions } from '../utils/ignorePatterns.js';
|
||||
import { shouldDefaultToNodePty } from '../utils/shell-utils.js';
|
||||
import { WorkspaceContext } from '../utils/workspaceContext.js';
|
||||
import { isToolEnabled, type ToolName } from '../utils/tool-utils.js';
|
||||
import { getErrorMessage } from '../utils/errors.js';
|
||||
|
|
@ -193,10 +194,6 @@ export interface ChatCompressionSettings {
|
|||
contextPercentageThreshold?: number;
|
||||
}
|
||||
|
||||
export interface SummarizeToolOutputSettings {
|
||||
tokenBudget?: number;
|
||||
}
|
||||
|
||||
export interface TelemetrySettings {
|
||||
enabled?: boolean;
|
||||
target?: TelemetryTarget;
|
||||
|
|
@ -296,6 +293,8 @@ export interface ConfigParameters {
|
|||
debugMode: boolean;
|
||||
includePartialMessages?: boolean;
|
||||
question?: string;
|
||||
systemPrompt?: string;
|
||||
appendSystemPrompt?: string;
|
||||
coreTools?: string[];
|
||||
allowedTools?: string[];
|
||||
excludeTools?: string[];
|
||||
|
|
@ -337,7 +336,6 @@ export interface ConfigParameters {
|
|||
allowedMcpServers?: string[];
|
||||
excludedMcpServers?: string[];
|
||||
noBrowser?: boolean;
|
||||
summarizeToolOutput?: Record<string, SummarizeToolOutputSettings>;
|
||||
folderTrustFeature?: boolean;
|
||||
folderTrust?: boolean;
|
||||
ideMode?: boolean;
|
||||
|
|
@ -373,7 +371,6 @@ export interface ConfigParameters {
|
|||
skipLoopDetection?: boolean;
|
||||
truncateToolOutputThreshold?: number;
|
||||
truncateToolOutputLines?: number;
|
||||
enableToolOutputTruncation?: boolean;
|
||||
eventEmitter?: EventEmitter;
|
||||
output?: OutputSettings;
|
||||
inputFormat?: InputFormat;
|
||||
|
|
@ -449,6 +446,8 @@ export class Config {
|
|||
private readonly outputFormat: OutputFormat;
|
||||
private readonly includePartialMessages: boolean;
|
||||
private readonly question: string | undefined;
|
||||
private readonly systemPrompt: string | undefined;
|
||||
private readonly appendSystemPrompt: string | undefined;
|
||||
private readonly coreTools: string[] | undefined;
|
||||
private readonly allowedTools: string[] | undefined;
|
||||
private readonly excludeTools: string[] | undefined;
|
||||
|
|
@ -496,9 +495,6 @@ export class Config {
|
|||
private readonly listExtensions: boolean;
|
||||
private readonly overrideExtensions?: string[];
|
||||
|
||||
private readonly summarizeToolOutput:
|
||||
| Record<string, SummarizeToolOutputSettings>
|
||||
| undefined;
|
||||
private readonly cliVersion?: string;
|
||||
private readonly experimentalZedIntegration: boolean = false;
|
||||
private readonly chatRecordingEnabled: boolean;
|
||||
|
|
@ -528,10 +524,9 @@ export class Config {
|
|||
private readonly fileExclusions: FileExclusions;
|
||||
private readonly truncateToolOutputThreshold: number;
|
||||
private readonly truncateToolOutputLines: number;
|
||||
private readonly enableToolOutputTruncation: boolean;
|
||||
private readonly eventEmitter?: EventEmitter;
|
||||
private readonly channel: string | undefined;
|
||||
private readonly defaultFileEncoding: FileEncodingType;
|
||||
private readonly defaultFileEncoding: FileEncodingType | undefined;
|
||||
private readonly enableHooks: boolean;
|
||||
private readonly hooks?: Record<string, unknown>;
|
||||
private readonly hooksConfig?: Record<string, unknown>;
|
||||
|
|
@ -559,6 +554,8 @@ export class Config {
|
|||
this.outputFormat = normalizedOutputFormat ?? OutputFormat.TEXT;
|
||||
this.includePartialMessages = params.includePartialMessages ?? false;
|
||||
this.question = params.question;
|
||||
this.systemPrompt = params.systemPrompt;
|
||||
this.appendSystemPrompt = params.appendSystemPrompt;
|
||||
this.coreTools = params.coreTools;
|
||||
this.allowedTools = params.allowedTools;
|
||||
this.excludeTools = params.excludeTools;
|
||||
|
|
@ -612,7 +609,6 @@ export class Config {
|
|||
this.listExtensions = params.listExtensions ?? false;
|
||||
this.overrideExtensions = params.overrideExtensions;
|
||||
this.noBrowser = params.noBrowser ?? false;
|
||||
this.summarizeToolOutput = params.summarizeToolOutput;
|
||||
this.folderTrustFeature = params.folderTrustFeature ?? false;
|
||||
this.folderTrust = params.folderTrust ?? false;
|
||||
this.ideMode = params.ideMode ?? false;
|
||||
|
|
@ -635,7 +631,8 @@ export class Config {
|
|||
this.webSearch = params.webSearch;
|
||||
this.useRipgrep = params.useRipgrep ?? true;
|
||||
this.useBuiltinRipgrep = params.useBuiltinRipgrep ?? true;
|
||||
this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? true;
|
||||
this.shouldUseNodePtyShell =
|
||||
params.shouldUseNodePtyShell ?? shouldDefaultToNodePty();
|
||||
this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? true;
|
||||
this.shellExecutionConfig = {
|
||||
terminalWidth: params.shellExecutionConfig?.terminalWidth ?? 80,
|
||||
|
|
@ -648,9 +645,8 @@ export class Config {
|
|||
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD;
|
||||
this.truncateToolOutputLines =
|
||||
params.truncateToolOutputLines ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES;
|
||||
this.enableToolOutputTruncation = params.enableToolOutputTruncation ?? true;
|
||||
this.channel = params.channel;
|
||||
this.defaultFileEncoding = params.defaultFileEncoding ?? FileEncoding.UTF8;
|
||||
this.defaultFileEncoding = params.defaultFileEncoding;
|
||||
this.storage = new Storage(this.targetDir);
|
||||
this.inputFormat = params.inputFormat ?? InputFormat.TEXT;
|
||||
this.fileExclusions = new FileExclusions(this);
|
||||
|
|
@ -1205,6 +1201,14 @@ export class Config {
|
|||
return this.question;
|
||||
}
|
||||
|
||||
getSystemPrompt(): string | undefined {
|
||||
return this.systemPrompt;
|
||||
}
|
||||
|
||||
getAppendSystemPrompt(): string | undefined {
|
||||
return this.appendSystemPrompt;
|
||||
}
|
||||
|
||||
getCoreTools(): string[] | undefined {
|
||||
return this.coreTools;
|
||||
}
|
||||
|
|
@ -1596,12 +1600,6 @@ export class Config {
|
|||
return this.getNoBrowser() || !shouldAttemptBrowserLaunch();
|
||||
}
|
||||
|
||||
getSummarizeToolOutputConfig():
|
||||
| Record<string, SummarizeToolOutputSettings>
|
||||
| undefined {
|
||||
return this.summarizeToolOutput;
|
||||
}
|
||||
|
||||
// Web search provider configuration
|
||||
getWebSearchConfig() {
|
||||
return this.webSearch;
|
||||
|
|
@ -1662,7 +1660,7 @@ export class Config {
|
|||
* Get the default file encoding for new files.
|
||||
* @returns FileEncodingType
|
||||
*/
|
||||
getDefaultFileEncoding(): FileEncodingType {
|
||||
getDefaultFileEncoding(): FileEncodingType | undefined {
|
||||
return this.defaultFileEncoding;
|
||||
}
|
||||
|
||||
|
|
@ -1730,15 +1728,8 @@ export class Config {
|
|||
return this.skipStartupContext;
|
||||
}
|
||||
|
||||
getEnableToolOutputTruncation(): boolean {
|
||||
return this.enableToolOutputTruncation;
|
||||
}
|
||||
|
||||
getTruncateToolOutputThreshold(): number {
|
||||
if (
|
||||
!this.enableToolOutputTruncation ||
|
||||
this.truncateToolOutputThreshold <= 0
|
||||
) {
|
||||
if (this.truncateToolOutputThreshold <= 0) {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
|
|
@ -1746,7 +1737,7 @@ export class Config {
|
|||
}
|
||||
|
||||
getTruncateToolOutputLines(): number {
|
||||
if (!this.enableToolOutputTruncation || this.truncateToolOutputLines <= 0) {
|
||||
if (this.truncateToolOutputLines <= 0) {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
|
|
@ -1892,6 +1883,7 @@ export class Config {
|
|||
registerCoreTool(ShellTool, this);
|
||||
registerCoreTool(MemoryTool);
|
||||
registerCoreTool(TodoWriteTool, this);
|
||||
registerCoreTool(AskUserQuestionTool, this);
|
||||
!this.sdkMode && registerCoreTool(ExitPlanModeTool, this);
|
||||
registerCoreTool(WebFetchTool, this);
|
||||
// Conditionally register web search tool if web search provider is configured
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue