mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-24 13:01:29 -07:00
Refactor PolicyEngine to Core Package (#12325)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -13,11 +13,11 @@ import type {
|
||||
} from './config.js';
|
||||
import {
|
||||
Config,
|
||||
ApprovalMode,
|
||||
DEFAULT_FILE_FILTERING_OPTIONS,
|
||||
HookType,
|
||||
HookEventName,
|
||||
} from './config.js';
|
||||
import { ApprovalMode } from '../policy/types.js';
|
||||
import * as path from 'node:path';
|
||||
import { setGeminiMdFilename as mockSetGeminiMdFilename } from '../tools/memoryTool.js';
|
||||
import {
|
||||
|
||||
@@ -78,11 +78,7 @@ import { AgentRegistry } from '../agents/registry.js';
|
||||
import { setGlobalProxy } from '../utils/fetch.js';
|
||||
import { SubagentToolWrapper } from '../agents/subagent-tool-wrapper.js';
|
||||
|
||||
export enum ApprovalMode {
|
||||
DEFAULT = 'default',
|
||||
AUTO_EDIT = 'autoEdit',
|
||||
YOLO = 'yolo',
|
||||
}
|
||||
import { ApprovalMode } from '../policy/types.js';
|
||||
|
||||
export interface AccessibilitySettings {
|
||||
disableLoadingPhrases?: boolean;
|
||||
@@ -152,7 +148,7 @@ import {
|
||||
DEFAULT_FILE_FILTERING_OPTIONS,
|
||||
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
|
||||
} from './constants.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
import {
|
||||
type ExtensionLoader,
|
||||
SimpleExtensionLoader,
|
||||
@@ -1243,19 +1239,11 @@ export class Config {
|
||||
// This first implementation is only focused on the general case of
|
||||
// the tool registry.
|
||||
const messageBusEnabled = this.getEnableMessageBusIntegration();
|
||||
if (this.debugMode && messageBusEnabled) {
|
||||
debugLogger.log(
|
||||
`[DEBUG] enableMessageBusIntegration setting: ${messageBusEnabled}`,
|
||||
);
|
||||
}
|
||||
|
||||
const toolArgs = messageBusEnabled
|
||||
? [...args, this.getMessageBus()]
|
||||
: args;
|
||||
if (this.debugMode && messageBusEnabled) {
|
||||
debugLogger.log(
|
||||
`[DEBUG] Registering ${className} with messageBus: ${messageBusEnabled ? 'YES' : 'NO'}`,
|
||||
);
|
||||
}
|
||||
|
||||
registry.registerTool(new ToolClass(...toolArgs));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,6 +58,23 @@ export class Storage {
|
||||
return path.join(Storage.getGlobalGeminiDir(), 'policies');
|
||||
}
|
||||
|
||||
static getSystemSettingsPath(): string {
|
||||
if (process.env['GEMINI_CLI_SYSTEM_SETTINGS_PATH']) {
|
||||
return process.env['GEMINI_CLI_SYSTEM_SETTINGS_PATH'];
|
||||
}
|
||||
if (os.platform() === 'darwin') {
|
||||
return '/Library/Application Support/GeminiCli/settings.json';
|
||||
} else if (os.platform() === 'win32') {
|
||||
return 'C:\\ProgramData\\gemini-cli\\settings.json';
|
||||
} else {
|
||||
return '/etc/gemini-cli/settings.json';
|
||||
}
|
||||
}
|
||||
|
||||
static getSystemPoliciesDir(): string {
|
||||
return path.join(path.dirname(Storage.getSystemSettingsPath()), 'policies');
|
||||
}
|
||||
|
||||
static getGlobalTempDir(): string {
|
||||
return path.join(Storage.getGlobalGeminiDir(), TMP_DIR_NAME);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user