Skip to content

feat: add command to modify granted always allow permissions #6902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ Slash commands provide meta-level control over the CLI itself.
- **Details:** This command provides a user-friendly interface for changing settings that control the behavior and appearance of Gemini CLI. It is equivalent to manually editing the `.gemini/settings.json` file, but with validation and guidance to prevent errors.
- **Usage:** Simply run `/settings` and the editor will open. You can then browse or search for specific settings, view their current values, and modify them as desired. Changes to some settings are applied immediately, while others require a restart.

- **`/permissions`**
- **Description:** Manage tool permissions and reset "Always Allow" settings.
- **Details:** This command provides an interactive interface for viewing and managing granular tool permissions that have been granted through "Always Allow" confirmations. You can see all currently granted permissions organized by tool type (Shell Commands, MCP Tools, Memory Operations, Global Settings) and selectively reset them.
- **Usage:** Simply run `/permissions` to open the permissions management dialog. Navigate between permission groups using arrow keys or vim keys (j/k), press 'r' to reset the selected group's permissions, or press 'A' to reset all permissions.
- **Permission Types:**
- **Shell Commands:** Commands that have been granted "always allow" permission for shell execution
- **MCP Tools:** Individual tools or entire servers from MCP (Model Context Protocol) that have been granted permanent access
- **Memory Operations:** Memory file operations that have been granted permanent access
- **Global Settings:** System-wide approval modes (like auto-approval for file edits)

- **`/stats`**
- **Description:** Display detailed statistics for the current Gemini CLI session, including token usage, cached token savings (when available), and session duration. Note: Cached token information is only displayed when cached tokens are being used, which occurs with API key authentication but not with OAuth authentication at this time.

Expand Down
19 changes: 19 additions & 0 deletions packages/cli/src/services/BuiltinCommandLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ vi.mock('../ui/commands/mcpCommand.js', () => ({
kind: 'BUILT_IN',
},
}));
vi.mock('../ui/commands/permissionsCommand.js', () => ({
permissionsCommand: {
name: 'permissions',
description: 'Manage tool permissions and reset "Always Allow" settings',
kind: 'BUILT_IN',
},
}));

describe('BuiltinCommandLoader', () => {
let mockConfig: Config;
Expand Down Expand Up @@ -124,4 +131,16 @@ describe('BuiltinCommandLoader', () => {
const mcpCmd = commands.find((c) => c.name === 'mcp');
expect(mcpCmd).toBeDefined();
});

it('should include the permissions command in the loaded commands', async () => {
const loader = new BuiltinCommandLoader(mockConfig);
const commands = await loader.loadCommands(new AbortController().signal);

const permissionsCmd = commands.find((c) => c.name === 'permissions');
expect(permissionsCmd).toBeDefined();
expect(permissionsCmd?.description).toBe(
'Manage tool permissions and reset "Always Allow" settings',
);
expect(permissionsCmd?.kind).toBe('BUILT_IN');
});
});
2 changes: 2 additions & 0 deletions packages/cli/src/services/BuiltinCommandLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { statsCommand } from '../ui/commands/statsCommand.js';
import { themeCommand } from '../ui/commands/themeCommand.js';
import { toolsCommand } from '../ui/commands/toolsCommand.js';
import { settingsCommand } from '../ui/commands/settingsCommand.js';
import { permissionsCommand } from '../ui/commands/permissionsCommand.js';
import { vimCommand } from '../ui/commands/vimCommand.js';
import { setupGithubCommand } from '../ui/commands/setupGithubCommand.js';
import { terminalSetupCommand } from '../ui/commands/terminalSetupCommand.js';
Expand Down Expand Up @@ -75,6 +76,7 @@ export class BuiltinCommandLoader implements ICommandLoader {
themeCommand,
toolsCommand,
settingsCommand,
permissionsCommand,
vimCommand,
setupGithubCommand,
terminalSetupCommand,
Expand Down
Loading
Loading