mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-13 12:57:12 -07:00
chore: clean up
This commit is contained in:
@@ -1860,8 +1860,8 @@ their corresponding top-level category object in your `settings.json` file.
|
||||
#### `admin`
|
||||
|
||||
- **`admin.secureModeEnabled`** (boolean):
|
||||
- **Description:** If true, disallows YOLO mode (wildcard policies) and "Always allow" options
|
||||
from being used.
|
||||
- **Description:** If true, disallows YOLO mode (wildcard policies) and
|
||||
"Always allow" options from being used.
|
||||
- **Default:** `false`
|
||||
|
||||
- **`admin.extensions.enabled`** (boolean):
|
||||
|
||||
@@ -353,16 +353,21 @@ describe('Task Event-Driven Scheduler', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should execute without confirmation in YOLO mode and not transition to input-required', async () => {
|
||||
// Enable YOLO mode
|
||||
const yoloConfig = createMockConfig({
|
||||
it('should execute without confirmation when wildcard policy is enabled and not transition to input-required', async () => {
|
||||
// Enable wildcard policy
|
||||
const wildcardConfig = createMockConfig({
|
||||
isEventDrivenSchedulerEnabled: () => true,
|
||||
getAllowedTools: () => ['*'],
|
||||
}) as Config;
|
||||
const yoloMessageBus = yoloConfig.messageBus;
|
||||
const wildcardMessageBus = wildcardConfig.messageBus;
|
||||
|
||||
// @ts-expect-error - Calling private constructor
|
||||
const task = new Task('task-id', 'context-id', yoloConfig, mockEventBus);
|
||||
const task = new Task(
|
||||
'task-id',
|
||||
'context-id',
|
||||
wildcardConfig,
|
||||
mockEventBus,
|
||||
);
|
||||
task.setTaskStateAndPublishUpdate = vi.fn();
|
||||
|
||||
const toolCall = {
|
||||
@@ -372,13 +377,13 @@ describe('Task Event-Driven Scheduler', () => {
|
||||
confirmationDetails: { type: 'info', title: 'test', prompt: 'test' },
|
||||
};
|
||||
|
||||
const handler = (yoloMessageBus.subscribe as Mock).mock.calls.find(
|
||||
const handler = (wildcardMessageBus.subscribe as Mock).mock.calls.find(
|
||||
(call: unknown[]) => call[0] === MessageBusType.TOOL_CALLS_UPDATE,
|
||||
)?.[1];
|
||||
handler({ type: MessageBusType.TOOL_CALLS_UPDATE, toolCalls: [toolCall] });
|
||||
|
||||
// Should NOT auto-publish ProceedOnce anymore, because PolicyEngine handles it directly
|
||||
expect(yoloMessageBus.publish).not.toHaveBeenCalledWith(
|
||||
expect(wildcardMessageBus.publish).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
||||
}),
|
||||
|
||||
@@ -407,8 +407,8 @@ describe('E2E Tests', () => {
|
||||
expect(events.length).toBe(7);
|
||||
});
|
||||
|
||||
it('should handle multiple tool calls sequentially in YOLO mode', async () => {
|
||||
// Set YOLO mode to auto-approve tools and test sequential execution.
|
||||
it('should handle multiple tool calls sequentially with wildcard policy', async () => {
|
||||
// Set wildcard policy to auto-approve tools and test sequential execution.
|
||||
getAllowedToolsSpy.mockReturnValue(['*']);
|
||||
|
||||
// First call yields the tool request
|
||||
@@ -680,15 +680,15 @@ describe('E2E Tests', () => {
|
||||
expect(events.length).toBe(10);
|
||||
});
|
||||
|
||||
it('should bypass tool approval in YOLO mode', async () => {
|
||||
it('should bypass tool approval with wildcard policy', async () => {
|
||||
// First call yields the tool request
|
||||
sendMessageStreamSpy.mockImplementationOnce(async function* () {
|
||||
yield* [
|
||||
{
|
||||
type: GeminiEventType.ToolCallRequest,
|
||||
value: {
|
||||
callId: 'test-call-id-yolo',
|
||||
name: 'test-tool-yolo',
|
||||
callId: 'test-call-id-wildcard',
|
||||
name: 'test-tool-wildcard',
|
||||
args: {},
|
||||
},
|
||||
},
|
||||
@@ -699,12 +699,12 @@ describe('E2E Tests', () => {
|
||||
yield* [{ type: 'content', value: 'Tool executed successfully.' }];
|
||||
});
|
||||
|
||||
// Set approval mode to yolo
|
||||
// Set approval mode to wildcard
|
||||
getAllowedToolsSpy.mockReturnValue(['*']);
|
||||
|
||||
const mockTool = new MockTool({
|
||||
name: 'test-tool-yolo',
|
||||
displayName: 'Test Tool YOLO',
|
||||
name: 'test-tool-wildcard',
|
||||
displayName: 'Test Tool WILDCARD',
|
||||
execute: vi.fn().mockResolvedValue({
|
||||
llmContent: 'Tool executed successfully.',
|
||||
returnDisplay: 'Tool executed successfully.',
|
||||
@@ -722,8 +722,8 @@ describe('E2E Tests', () => {
|
||||
.post('/')
|
||||
.send(
|
||||
createStreamMessageRequest(
|
||||
'run a tool in yolo mode',
|
||||
'a2a-yolo-mode-test-message',
|
||||
'run a tool in wildcard mode',
|
||||
'a2a-wildcard-mode-test-message',
|
||||
),
|
||||
)
|
||||
.set('Content-Type', 'application/json')
|
||||
@@ -746,7 +746,7 @@ describe('E2E Tests', () => {
|
||||
{
|
||||
data: {
|
||||
status: 'validating',
|
||||
request: { callId: 'test-call-id-yolo' },
|
||||
request: { callId: 'test-call-id-wildcard' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
@@ -760,7 +760,7 @@ describe('E2E Tests', () => {
|
||||
{
|
||||
data: {
|
||||
status: 'scheduled',
|
||||
request: { callId: 'test-call-id-yolo' },
|
||||
request: { callId: 'test-call-id-wildcard' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
@@ -774,7 +774,7 @@ describe('E2E Tests', () => {
|
||||
{
|
||||
data: {
|
||||
status: 'executing',
|
||||
request: { callId: 'test-call-id-yolo' },
|
||||
request: { callId: 'test-call-id-wildcard' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
@@ -788,7 +788,7 @@ describe('E2E Tests', () => {
|
||||
{
|
||||
data: {
|
||||
status: 'success',
|
||||
request: { callId: 'test-call-id-yolo' },
|
||||
request: { callId: 'test-call-id-wildcard' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Example Policy Rules for Gemini CLI Extension
|
||||
#
|
||||
# Extensions run in Tier 2 (Extension Tier).
|
||||
# Security Note: 'allow' decisions and 'yolo' mode configurations are ignored.
|
||||
# Security Note: 'allow' decisions and wildcard policies are ignored.
|
||||
|
||||
# Rule: Always ask the user before running a specific dangerous shell command.
|
||||
[[rule]]
|
||||
|
||||
@@ -158,7 +158,7 @@ vi.mock('@google/gemini-cli-core', async () => {
|
||||
),
|
||||
getAdminErrorMessage: vi.fn(
|
||||
(_feature) =>
|
||||
`YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli`,
|
||||
`Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli`,
|
||||
),
|
||||
isHeadlessMode: vi.fn((opts) => {
|
||||
if (process.env['VITEST'] === 'true') {
|
||||
@@ -1445,7 +1445,7 @@ describe('Approval mode tool exclusion logic', () => {
|
||||
expect(excludedTools).toContain(ASK_USER_TOOL_NAME);
|
||||
});
|
||||
|
||||
it('should throw an error if YOLO mode is attempted when disableYoloMode is true', async () => {
|
||||
it('should throw an error if wildcard policy is attempted when disableYoloMode is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const settings = createTestMergedSettings({
|
||||
@@ -1455,7 +1455,7 @@ describe('Approval mode tool exclusion logic', () => {
|
||||
});
|
||||
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1472,7 +1472,7 @@ describe('Approval mode tool exclusion logic', () => {
|
||||
await expect(
|
||||
loadCliConfig(settings, 'test-session', invalidArgv as CliArgs),
|
||||
).rejects.toThrow(
|
||||
'Invalid approval mode: invalid_mode. Valid values are: auto_edit, plan, default (yolo is mapped to allowed-tools)',
|
||||
'Invalid approval mode: invalid_mode. Valid values are: auto_edit, plan, default ',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2332,7 +2332,7 @@ describe('loadCliConfig tool exclusions', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should not exclude interactive tools in interactive mode without YOLO', async () => {
|
||||
it('should not exclude interactive tools in interactive mode without wildcard', async () => {
|
||||
process.stdin.isTTY = true;
|
||||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
@@ -2347,7 +2347,7 @@ describe('loadCliConfig tool exclusions', () => {
|
||||
expect(config.getExcludeTools()).not.toContain('ask_user');
|
||||
});
|
||||
|
||||
it('should not exclude interactive tools in interactive mode with YOLO', async () => {
|
||||
it('should not exclude interactive tools in interactive mode with wildcard', async () => {
|
||||
process.stdin.isTTY = true;
|
||||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
@@ -2362,7 +2362,7 @@ describe('loadCliConfig tool exclusions', () => {
|
||||
expect(config.getExcludeTools()).not.toContain('ask_user');
|
||||
});
|
||||
|
||||
it('should exclude interactive tools in non-interactive mode without YOLO', async () => {
|
||||
it('should exclude interactive tools in non-interactive mode without wildcard', async () => {
|
||||
process.stdin.isTTY = false;
|
||||
process.argv = ['node', 'script.js', '-p', 'test'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
@@ -2377,7 +2377,7 @@ describe('loadCliConfig tool exclusions', () => {
|
||||
expect(config.getExcludeTools()).toContain('ask_user');
|
||||
});
|
||||
|
||||
it('should exclude only ask_user in non-interactive mode with YOLO', async () => {
|
||||
it('should exclude only ask_user in non-interactive mode with wildcard', async () => {
|
||||
process.stdin.isTTY = false;
|
||||
process.argv = ['node', 'script.js', '-p', 'test', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
@@ -2742,7 +2742,7 @@ describe('loadCliConfig approval mode', () => {
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
||||
});
|
||||
|
||||
it('should set YOLO approval mode when --yolo flag is used', async () => {
|
||||
it('should set wildcard allowed tools when --yolo flag is used', async () => {
|
||||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(
|
||||
@@ -2751,9 +2751,10 @@ describe('loadCliConfig approval mode', () => {
|
||||
argv,
|
||||
);
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
||||
expect(config.getAllowedTools()).toEqual(['*']);
|
||||
});
|
||||
|
||||
it('should set YOLO approval mode when -y flag is used', async () => {
|
||||
it('should set wildcard allowed tools when -y flag is used', async () => {
|
||||
process.argv = ['node', 'script.js', '-y'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(
|
||||
@@ -2762,6 +2763,7 @@ describe('loadCliConfig approval mode', () => {
|
||||
argv,
|
||||
);
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
||||
expect(config.getAllowedTools()).toEqual(['*']);
|
||||
});
|
||||
|
||||
it('should set DEFAULT approval mode when --approval-mode=default', async () => {
|
||||
@@ -2786,7 +2788,7 @@ describe('loadCliConfig approval mode', () => {
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.AUTO_EDIT);
|
||||
});
|
||||
|
||||
it('should set YOLO approval mode when --approval-mode=yolo', async () => {
|
||||
it('should set wildcard allowed tools when --approval-mode=yolo', async () => {
|
||||
process.argv = ['node', 'script.js', '--approval-mode', 'yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(
|
||||
@@ -2795,6 +2797,7 @@ describe('loadCliConfig approval mode', () => {
|
||||
argv,
|
||||
);
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
||||
expect(config.getAllowedTools()).toEqual(['*']);
|
||||
});
|
||||
|
||||
it('should prioritize --approval-mode over --yolo when both would be valid (but validation prevents this)', async () => {
|
||||
@@ -2821,6 +2824,7 @@ describe('loadCliConfig approval mode', () => {
|
||||
argv,
|
||||
);
|
||||
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
||||
expect(config.getAllowedTools()).toEqual(['*']);
|
||||
});
|
||||
|
||||
it('should set Plan approval mode when --approval-mode=plan is used and plan is enabled', async () => {
|
||||
@@ -3629,14 +3633,25 @@ describe('loadCliConfig disableYoloMode', () => {
|
||||
expect(config.getApprovalMode()).toBe(ApprovalMode.AUTO_EDIT);
|
||||
});
|
||||
|
||||
it('should throw if YOLO mode is attempted when disableYoloMode is true', async () => {
|
||||
it('should throw if wildcard policy is attempted when disableYoloMode is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const settings = createTestMergedSettings({
|
||||
security: { disableYoloMode: true },
|
||||
});
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if wildcard tools are requested when disableYoloMode is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--allowed-tools=*'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const settings = createTestMergedSettings({
|
||||
security: { disableYoloMode: true },
|
||||
});
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -3658,7 +3673,7 @@ describe('loadCliConfig secureModeEnabled', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should throw an error if YOLO mode is attempted when secureModeEnabled is true', async () => {
|
||||
it('should throw an error if wildcard policy is attempted when secureModeEnabled is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const settings = createTestMergedSettings({
|
||||
@@ -3668,7 +3683,7 @@ describe('loadCliConfig secureModeEnabled', () => {
|
||||
});
|
||||
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3682,7 +3697,21 @@ describe('loadCliConfig secureModeEnabled', () => {
|
||||
});
|
||||
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if wildcard tools are requested when secureModeEnabled is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--allowed-tools=*'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const settings = createTestMergedSettings({
|
||||
admin: {
|
||||
secureModeEnabled: true,
|
||||
},
|
||||
});
|
||||
|
||||
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(
|
||||
'Wildcard policies are disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@ export async function loadCliConfig(
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Invalid approval mode: ${rawApprovalMode}. Valid values are: auto_edit, plan, default (yolo is mapped to allowed-tools)`,
|
||||
`Invalid approval mode: ${rawApprovalMode}. Valid values are: auto_edit, plan, default`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -700,20 +700,20 @@ export async function loadCliConfig(
|
||||
if (isYoloRequested || allowedTools.includes('*')) {
|
||||
if (settings.admin?.secureModeEnabled) {
|
||||
debugLogger.error(
|
||||
'YOLO mode (wildcard policies) are disabled by "secureModeEnabled" setting.',
|
||||
'Wildcard policies are disabled by "secureModeEnabled" setting.',
|
||||
);
|
||||
} else {
|
||||
debugLogger.error(
|
||||
'YOLO mode (wildcard policies) are disabled by the "disableYolo" setting.',
|
||||
'Wildcard policies are disabled by the "disableYolo" setting.',
|
||||
);
|
||||
}
|
||||
throw new FatalConfigError(
|
||||
getAdminErrorMessage('YOLO mode', undefined /* config */),
|
||||
getAdminErrorMessage('Wildcard policies', undefined /* config */),
|
||||
);
|
||||
}
|
||||
} else if (isYoloRequested) {
|
||||
debugLogger.warn(
|
||||
'YOLO mode is enabled via flag or setting. All tool calls will be automatically approved by a wildcard policy.',
|
||||
'Wildcard policy is enabled via flag or setting. All tool calls will be automatically approved.',
|
||||
);
|
||||
if (!allowedTools.includes('*')) {
|
||||
allowedTools = [...allowedTools, '*'];
|
||||
|
||||
@@ -2626,7 +2626,7 @@ const SETTINGS_SCHEMA = {
|
||||
requiresRestart: false,
|
||||
default: false,
|
||||
description:
|
||||
'If true, disallows YOLO mode and "Always allow" options from being used.',
|
||||
'If true, disallows YOLO mode (wildcard policies) and "Always allow" options from being used.',
|
||||
showInDialog: false,
|
||||
mergeStrategy: MergeStrategy.REPLACE,
|
||||
},
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('ApprovalModeIndicator', () => {
|
||||
const { lastFrame, waitUntilReady } = await render(
|
||||
<ApprovalModeIndicator
|
||||
approvalMode={ApprovalMode.DEFAULT}
|
||||
isYoloMode={true}
|
||||
isWildcardPolicyEnabled={true}
|
||||
/>,
|
||||
);
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
|
||||
@@ -14,13 +14,13 @@ import { Command } from '../key/keyBindings.js';
|
||||
interface ApprovalModeIndicatorProps {
|
||||
approvalMode: ApprovalMode;
|
||||
allowPlanMode?: boolean;
|
||||
isYoloMode?: boolean;
|
||||
isWildcardPolicyEnabled?: boolean;
|
||||
}
|
||||
|
||||
export const ApprovalModeIndicator: React.FC<ApprovalModeIndicatorProps> = ({
|
||||
approvalMode,
|
||||
allowPlanMode,
|
||||
isYoloMode,
|
||||
isWildcardPolicyEnabled,
|
||||
}) => {
|
||||
let textColor = '';
|
||||
let textContent = '';
|
||||
@@ -28,9 +28,9 @@ export const ApprovalModeIndicator: React.FC<ApprovalModeIndicatorProps> = ({
|
||||
|
||||
const cycleHint = formatCommand(Command.CYCLE_APPROVAL_MODE);
|
||||
|
||||
if (isYoloMode) {
|
||||
if (isWildcardPolicyEnabled) {
|
||||
textColor = theme.status.error;
|
||||
textContent = 'YOLO';
|
||||
textContent = 'WILDCARD';
|
||||
subText = '';
|
||||
} else {
|
||||
switch (approvalMode) {
|
||||
|
||||
@@ -640,7 +640,7 @@ describe('Composer', () => {
|
||||
},
|
||||
);
|
||||
|
||||
it('shows ApprovalModeIndicator when YOLO mode is active and shell mode is inactive', async () => {
|
||||
it('shows ApprovalModeIndicator when wildcard policy is active and shell mode is inactive', async () => {
|
||||
const config = createMockConfig({
|
||||
getAllowedTools: vi.fn(() => ['*']),
|
||||
});
|
||||
@@ -703,7 +703,7 @@ describe('Composer', () => {
|
||||
},
|
||||
);
|
||||
|
||||
it('shows minimal mode badge "YOLO" when clean UI details are hidden and YOLO mode is active', async () => {
|
||||
it('shows minimal mode badge "WILDCARD" when clean UI details are hidden and wildcard policy is active', async () => {
|
||||
const config = createMockConfig({
|
||||
getAllowedTools: vi.fn(() => ['*']),
|
||||
});
|
||||
@@ -713,7 +713,7 @@ describe('Composer', () => {
|
||||
});
|
||||
|
||||
const { lastFrame } = await renderComposer(uiState, undefined, config);
|
||||
expect(lastFrame()).toContain('YOLO');
|
||||
expect(lastFrame()).toContain('WILDCARD');
|
||||
});
|
||||
|
||||
it('hides minimal mode badge while loading in clean mode', async () => {
|
||||
|
||||
@@ -77,7 +77,7 @@ export const Composer = ({ isFocused = true }: { isFocused?: boolean }) => {
|
||||
const hasToast = shouldShowToast(uiState);
|
||||
const hideUiDetailsForSuggestions =
|
||||
suggestionsVisible && suggestionsPosition === 'above';
|
||||
const isYoloMode = config.getAllowedTools()?.includes('*');
|
||||
const isWildcardPolicyEnabled = config.getAllowedTools()?.includes('*');
|
||||
|
||||
// Mini Mode VIP Flags (Pure Content Triggers)
|
||||
const showMinimalToast = hasToast;
|
||||
@@ -148,7 +148,7 @@ export const Composer = ({ isFocused = true }: { isFocused?: boolean }) => {
|
||||
shellModeActive={uiState.shellModeActive}
|
||||
setShellModeActive={uiActions.setShellModeActive}
|
||||
approvalMode={uiState.showApprovalModeIndicator}
|
||||
isYoloMode={isYoloMode}
|
||||
isWildcardPolicyEnabled={isWildcardPolicyEnabled}
|
||||
onEscapePromptChange={uiActions.onEscapePromptChange}
|
||||
focus={isFocused}
|
||||
vimHandleInput={uiActions.vimHandleInput}
|
||||
|
||||
@@ -110,7 +110,7 @@ export interface InputPromptProps {
|
||||
shellModeActive: boolean;
|
||||
setShellModeActive: (value: boolean) => void;
|
||||
approvalMode: ApprovalMode;
|
||||
isYoloMode?: boolean;
|
||||
isWildcardPolicyEnabled?: boolean;
|
||||
onEscapePromptChange?: (showPrompt: boolean) => void;
|
||||
onSuggestionsVisibilityChange?: (visible: boolean) => void;
|
||||
vimHandleInput?: (key: Key) => boolean;
|
||||
@@ -206,7 +206,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
shellModeActive,
|
||||
setShellModeActive,
|
||||
approvalMode,
|
||||
isYoloMode,
|
||||
isWildcardPolicyEnabled,
|
||||
onEscapePromptChange,
|
||||
onSuggestionsVisibilityChange,
|
||||
vimHandleInput,
|
||||
@@ -1491,7 +1491,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
|
||||
const showAutoAcceptStyling =
|
||||
!shellModeActive && approvalMode === ApprovalMode.AUTO_EDIT;
|
||||
const showYoloStyling = !shellModeActive && isYoloMode;
|
||||
const showWildcardStyling = !shellModeActive && isWildcardPolicyEnabled;
|
||||
const showPlanStyling =
|
||||
!shellModeActive && approvalMode === ApprovalMode.PLAN;
|
||||
|
||||
@@ -1500,9 +1500,9 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
if (shellModeActive) {
|
||||
statusColor = theme.ui.symbol;
|
||||
statusText = 'Shell mode';
|
||||
} else if (showYoloStyling) {
|
||||
} else if (showWildcardStyling) {
|
||||
statusColor = theme.status.error;
|
||||
statusText = 'YOLO mode';
|
||||
statusText = 'Wildcard policy';
|
||||
} else if (showPlanStyling) {
|
||||
statusColor = theme.status.success;
|
||||
statusText = 'Plan mode';
|
||||
@@ -1590,7 +1590,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
)
|
||||
) : commandSearchActive ? (
|
||||
<Text color={theme.text.accent}>(r:) </Text>
|
||||
) : showYoloStyling ? (
|
||||
) : showWildcardStyling ? (
|
||||
'*'
|
||||
) : (
|
||||
'>'
|
||||
|
||||
@@ -26,6 +26,6 @@ exports[`ApprovalModeIndicator > renders correctly for PLAN mode 1`] = `
|
||||
`;
|
||||
|
||||
exports[`ApprovalModeIndicator > renders correctly for YOLO mode 1`] = `
|
||||
"YOLO
|
||||
"WILDCARD
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -599,27 +599,27 @@ describe('Core System Prompt (prompts.ts)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should include YOLO mode instructions in interactive mode', () => {
|
||||
it('should include wildcard policy instructions in interactive mode', () => {
|
||||
vi.mocked(mockConfig.getAllowedTools).mockReturnValue(['*']);
|
||||
vi.mocked(mockConfig.isInteractive).mockReturnValue(true);
|
||||
const prompt = getCoreSystemPrompt(mockConfig);
|
||||
expect(prompt).toContain('# Autonomous Mode (YOLO)');
|
||||
expect(prompt).toContain('# Autonomous Mode (Wildcard Policy)');
|
||||
expect(prompt).toContain('Only use the `ask_user` tool if');
|
||||
});
|
||||
|
||||
it('should NOT include YOLO mode instructions in non-interactive mode', () => {
|
||||
it('should NOT include wildcard policy instructions in non-interactive mode', () => {
|
||||
vi.mocked(mockConfig.getAllowedTools).mockReturnValue(['*']);
|
||||
vi.mocked(mockConfig.isInteractive).mockReturnValue(false);
|
||||
const prompt = getCoreSystemPrompt(mockConfig);
|
||||
expect(prompt).not.toContain('# Autonomous Mode (YOLO)');
|
||||
expect(prompt).not.toContain('# Autonomous Mode (Wildcard Policy)');
|
||||
});
|
||||
|
||||
it('should NOT include YOLO mode instructions for DEFAULT mode', () => {
|
||||
it('should NOT include wildcard policy instructions for DEFAULT mode', () => {
|
||||
vi.mocked(mockConfig.getApprovalMode).mockReturnValue(
|
||||
ApprovalMode.DEFAULT,
|
||||
);
|
||||
const prompt = getCoreSystemPrompt(mockConfig);
|
||||
expect(prompt).not.toContain('# Autonomous Mode (YOLO)');
|
||||
expect(prompt).not.toContain('# Autonomous Mode (Wildcard Policy)');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ export const ALWAYS_ALLOW_PRIORITY_OFFSET =
|
||||
ALWAYS_ALLOW_PRIORITY_FRACTION / 1000;
|
||||
|
||||
/**
|
||||
* Priority for the YOLO "allow all" rule.
|
||||
* Matches the raw priority used in yolo.toml.
|
||||
* Priority for the wildcard "allow all" rule.
|
||||
* Matches the raw priority previously used for the wildcard allow all override.
|
||||
*/
|
||||
export const PRIORITY_YOLO_ALLOW_ALL = 998;
|
||||
export const PRIORITY_WILDCARD_ALLOW_ALL = 998;
|
||||
|
||||
@@ -331,7 +331,7 @@ You are running outside of a sandbox container, directly on the user's system. F
|
||||
export function renderInteractiveYoloMode(enabled?: boolean): string {
|
||||
if (!enabled) return '';
|
||||
return `
|
||||
# Autonomous Mode (YOLO)
|
||||
# Autonomous Mode (Wildcard Policy)
|
||||
|
||||
You are operating in **autonomous mode**. The user has requested minimal interruption.
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ export function renderSandbox(options?: SandboxOptions): string {
|
||||
export function renderInteractiveYoloMode(enabled?: boolean): string {
|
||||
if (!enabled) return '';
|
||||
return `
|
||||
# Autonomous Mode (YOLO)
|
||||
# Autonomous Mode (Wildcard Policy)
|
||||
|
||||
You are operating in **autonomous mode**. The user has requested minimal interruption.
|
||||
|
||||
|
||||
@@ -3251,8 +3251,8 @@
|
||||
"properties": {
|
||||
"secureModeEnabled": {
|
||||
"title": "Secure Mode Enabled",
|
||||
"description": "If true, disallows YOLO mode and \"Always allow\" options from being used.",
|
||||
"markdownDescription": "If true, disallows YOLO mode and \"Always allow\" options from being used.\n\n- Category: `Admin`\n- Requires restart: `no`\n- Default: `false`",
|
||||
"description": "If true, disallows YOLO mode (wildcard policies) and \"Always allow\" options from being used.",
|
||||
"markdownDescription": "If true, disallows YOLO mode (wildcard policies) and \"Always allow\" options from being used.\n\n- Category: `Admin`\n- Requires restart: `no`\n- Default: `false`",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user