extensions/cli/src/permissions/README.md
The tool permissions system allows you to control which tools the AI can use and how it can use them. There are three permission levels:
The system comes with sensible default policies:
readFile, listFiles, searchCode, fetch) are allowed by defaultwriteFile) require confirmation (ask)runTerminalCommand) require confirmation (ask)Tools with "exclude" permission are filtered out before being sent to the AI model. This means the AI won't even know these tools exist.
When the AI tries to use a tool with "ask" permission, the system will:
Tools with "allow" permission are executed immediately without user intervention.
types.ts: Defines the permission policy types and interfacesdefaultPolicies.ts: Contains the hardcoded default permission policiespermissionChecker.ts: Implements the permission checking logicpermissionManager.ts: Manages permission requests and user responsesgetAllowedTools() in streamChatResponse.ts filters out excluded toolsThe permission system integrates with the existing chat UI:
The system is designed to be extensible for future features like:
// Check permission for a tool call
const result = checkToolPermission({
name: "writeFile",
arguments: { path: "/important.txt", content: "data" },
});
if (result.permission === "ask") {
// Request user permission
}