mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 03:54:43 -07:00
feat: Update permissions command to support modifying trust for other… (#11642)
This commit is contained in:
@@ -4,15 +4,80 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type { OpenDialogActionReturn, SlashCommand } from './types.js';
|
||||
import type {
|
||||
OpenDialogActionReturn,
|
||||
SlashCommand,
|
||||
SlashCommandActionReturn,
|
||||
} from './types.js';
|
||||
import { CommandKind } from './types.js';
|
||||
import * as process from 'node:process';
|
||||
import * as path from 'node:path';
|
||||
import * as fs from 'node:fs';
|
||||
import { expandHomeDir } from '../utils/directoryUtils.js';
|
||||
|
||||
export const permissionsCommand: SlashCommand = {
|
||||
name: 'permissions',
|
||||
description: 'Manage folder trust settings',
|
||||
description: 'Manage folder trust settings and other permissions',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: (): OpenDialogActionReturn => ({
|
||||
type: 'dialog',
|
||||
dialog: 'permissions',
|
||||
}),
|
||||
subCommands: [
|
||||
{
|
||||
name: 'trust',
|
||||
description:
|
||||
'Manage folder trust settings. Usage: /permissions trust [<directory-path>]',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: (context, input): SlashCommandActionReturn => {
|
||||
const dirPath = input.trim();
|
||||
let targetDirectory: string;
|
||||
|
||||
if (!dirPath) {
|
||||
targetDirectory = process.cwd();
|
||||
} else {
|
||||
targetDirectory = path.resolve(expandHomeDir(dirPath));
|
||||
}
|
||||
|
||||
try {
|
||||
if (!fs.statSync(targetDirectory).isDirectory()) {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: `Path is not a directory: ${targetDirectory}`,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message : String(e);
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: `Error accessing path: ${targetDirectory}. ${message}`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'dialog',
|
||||
dialog: 'permissions',
|
||||
props: {
|
||||
targetDirectory,
|
||||
},
|
||||
} as OpenDialogActionReturn;
|
||||
},
|
||||
},
|
||||
],
|
||||
action: (context, input): SlashCommandActionReturn => {
|
||||
const parts = input.trim().split(' ');
|
||||
const subcommand = parts[0];
|
||||
|
||||
if (!subcommand) {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: `Please provide a subcommand for /permissions. Usage: /permissions trust [<directory-path>]`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: `Invalid subcommand for /permissions: ${subcommand}. Usage: /permissions trust [<directory-path>]`,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user