mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
add excludeTools flag to settings.json config (#957)
This commit is contained in:
@@ -44,6 +44,7 @@ vi.mock('@gemini-cli/core', async () => {
|
||||
getQuestion: () => params.question,
|
||||
getFullContext: () => params.fullContext,
|
||||
getCoreTools: () => params.coreTools,
|
||||
getExcludeTools: () => params.excludeTools,
|
||||
getToolDiscoveryCommand: () => params.toolDiscoveryCommand,
|
||||
getToolCallCommand: () => params.toolCallCommand,
|
||||
getMcpServerCommand: () => params.mcpServerCommand,
|
||||
|
||||
@@ -175,6 +175,7 @@ export async function loadCliConfig(
|
||||
question: argv.prompt || '',
|
||||
fullContext: argv.all_files || false,
|
||||
coreTools: settings.coreTools || undefined,
|
||||
excludeTools: settings.excludeTools || undefined,
|
||||
toolDiscoveryCommand: settings.toolDiscoveryCommand,
|
||||
toolCallCommand: settings.toolCallCommand,
|
||||
mcpServerCommand: settings.mcpServerCommand,
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface Settings {
|
||||
theme?: string;
|
||||
sandbox?: boolean | string;
|
||||
coreTools?: string[];
|
||||
excludeTools?: string[];
|
||||
toolDiscoveryCommand?: string;
|
||||
toolCallCommand?: string;
|
||||
mcpServerCommand?: string;
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface ConfigParameters {
|
||||
question?: string;
|
||||
fullContext?: boolean;
|
||||
coreTools?: string[];
|
||||
excludeTools?: string[];
|
||||
toolDiscoveryCommand?: string;
|
||||
toolCallCommand?: string;
|
||||
mcpServerCommand?: string;
|
||||
@@ -95,6 +96,7 @@ export class Config {
|
||||
private readonly question: string | undefined;
|
||||
private readonly fullContext: boolean;
|
||||
private readonly coreTools: string[] | undefined;
|
||||
private readonly excludeTools: string[] | undefined;
|
||||
private readonly toolDiscoveryCommand: string | undefined;
|
||||
private readonly toolCallCommand: string | undefined;
|
||||
private readonly mcpServerCommand: string | undefined;
|
||||
@@ -126,6 +128,7 @@ export class Config {
|
||||
this.question = params.question;
|
||||
this.fullContext = params.fullContext ?? false;
|
||||
this.coreTools = params.coreTools;
|
||||
this.excludeTools = params.excludeTools;
|
||||
this.toolDiscoveryCommand = params.toolDiscoveryCommand;
|
||||
this.toolCallCommand = params.toolCallCommand;
|
||||
this.mcpServerCommand = params.mcpServerCommand;
|
||||
@@ -210,6 +213,10 @@ export class Config {
|
||||
return this.coreTools;
|
||||
}
|
||||
|
||||
getExcludeTools(): string[] | undefined {
|
||||
return this.excludeTools;
|
||||
}
|
||||
|
||||
getToolDiscoveryCommand(): string | undefined {
|
||||
return this.toolDiscoveryCommand;
|
||||
}
|
||||
@@ -360,12 +367,22 @@ export function createToolRegistry(config: Config): Promise<ToolRegistry> {
|
||||
const tools = config.getCoreTools()
|
||||
? new Set(config.getCoreTools())
|
||||
: undefined;
|
||||
const excludeTools = config.getExcludeTools()
|
||||
? new Set(config.getExcludeTools())
|
||||
: undefined;
|
||||
|
||||
// helper to create & register core tools that are enabled
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const registerCoreTool = (ToolClass: any, ...args: unknown[]) => {
|
||||
// check both the tool name (.Name) and the class name (.name)
|
||||
if (!tools || tools.has(ToolClass.Name) || tools.has(ToolClass.name)) {
|
||||
if (
|
||||
// coreTools contain tool name
|
||||
(!tools || tools.has(ToolClass.Name) || tools.has(ToolClass.name)) &&
|
||||
// excludeTools don't contain tool name
|
||||
(!excludeTools ||
|
||||
(!excludeTools.has(ToolClass.Name) &&
|
||||
!excludeTools.has(ToolClass.name)))
|
||||
) {
|
||||
registry.registerTool(new ToolClass(...args));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user