mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
92efe6fdef
Claude Code shipped Auto Mode in March 2026 as a new permission mode value (`auto`) — autonomous execution gated by a Sonnet 4.6 safety classifier. It sits between `acceptEdits` and `bypassPermissions` in risk profile. Extend the `PermissionMode` union and `PERMISSION_MODE_OPTIONS` array with the `auto` entry. The Settings dropdown and first-time setup modal both iterate the options array, so no UI component changes are needed. The hook stdout payload (`updatedPermissions[].mode`) is already generic over mode value, so server-side plumbing also requires no changes. Refs: - https://www.anthropic.com/engineering/claude-code-auto-mode - https://code.claude.com/docs/en/permission-modes
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
/**
|
|
* Permission Mode Settings Utility (Claude Code only)
|
|
*
|
|
* Manages the preferred permission mode to restore after plan approval.
|
|
* Claude Code 2.1.7+ supports updatedPermissions in hook responses.
|
|
*
|
|
* Available modes:
|
|
* - acceptEdits: Auto-approve file edits only
|
|
* - auto: Autonomous execution gated by a model-based safety classifier (Claude Code 2026-03+, Sonnet 4.6+)
|
|
* - bypassPermissions: Auto-approve all tool calls
|
|
* - default: Manually approve each tool call
|
|
*/
|
|
|
|
import { storage } from './storage';
|
|
|
|
const STORAGE_KEY_MODE = 'plannotator-permission-mode';
|
|
const STORAGE_KEY_CONFIGURED = 'plannotator-permission-mode-configured';
|
|
|
|
export type PermissionMode = 'bypassPermissions' | 'acceptEdits' | 'auto' | 'default';
|
|
|
|
export interface PermissionModeSettings {
|
|
mode: PermissionMode;
|
|
configured: boolean; // Whether user has explicitly set this
|
|
}
|
|
|
|
export const PERMISSION_MODE_OPTIONS: { value: PermissionMode; label: string; description: string }[] = [
|
|
{
|
|
value: 'acceptEdits',
|
|
label: 'Auto-accept Edits',
|
|
description: 'Auto-approve file edits, ask for other tools',
|
|
},
|
|
{
|
|
value: 'auto',
|
|
label: 'Auto Mode',
|
|
description: 'Autonomous execution with a safety classifier (requires Claude Code 2026-03+ and Sonnet 4.6+)',
|
|
},
|
|
{
|
|
value: 'bypassPermissions',
|
|
label: 'Bypass Permissions',
|
|
description: 'Auto-approve all tool calls (equivalent to --dangerously-skip-permissions)',
|
|
},
|
|
{
|
|
value: 'default',
|
|
label: 'Manual Approval',
|
|
description: 'Manually approve each tool call',
|
|
},
|
|
];
|
|
|
|
const DEFAULT_MODE: PermissionMode = 'acceptEdits';
|
|
|
|
/**
|
|
* Get current permission mode settings from storage
|
|
*/
|
|
export function getPermissionModeSettings(): PermissionModeSettings {
|
|
const mode = storage.getItem(STORAGE_KEY_MODE) as PermissionMode | null;
|
|
const configured = storage.getItem(STORAGE_KEY_CONFIGURED) === 'true';
|
|
|
|
return {
|
|
mode: mode || DEFAULT_MODE,
|
|
configured,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Save permission mode settings to storage
|
|
*/
|
|
export function savePermissionModeSettings(mode: PermissionMode): void {
|
|
storage.setItem(STORAGE_KEY_MODE, mode);
|
|
storage.setItem(STORAGE_KEY_CONFIGURED, 'true');
|
|
}
|
|
|
|
/**
|
|
* Check if the user needs to configure their permission mode preference
|
|
*/
|
|
export function needsPermissionModeSetup(): boolean {
|
|
return storage.getItem(STORAGE_KEY_CONFIGURED) !== 'true';
|
|
}
|