feat(server): Implement Cursor CLI permissions management

Added new routes and handlers for managing Cursor CLI permissions, including:
- GET /api/setup/cursor-permissions: Retrieve current permissions configuration and available profiles.
- POST /api/setup/cursor-permissions/profile: Apply a predefined permission profile (global or project).
- POST /api/setup/cursor-permissions/custom: Set custom permissions for a project.
- DELETE /api/setup/cursor-permissions: Delete project-level permissions, reverting to global settings.
- GET /api/setup/cursor-permissions/example: Provide an example config file for a specified profile.

Also introduced a new service for handling Cursor CLI configuration files and updated the UI to support permissions management.

Affected files:
- Added new routes in index.ts and cursor-config.ts
- Created cursor-config-service.ts for permissions management logic
- Updated UI components to display and manage permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
Kacper
2025-12-30 17:08:18 +01:00
parent 078ab943a8
commit dac916496c
6 changed files with 1121 additions and 5 deletions

View File

@@ -562,6 +562,73 @@ export class HttpApiClient implements ElectronAPI {
error?: string;
}> => this.post('/api/setup/cursor-config/models', { projectPath, models }),
// Cursor CLI Permissions
getCursorPermissions: (
projectPath?: string
): Promise<{
success: boolean;
globalPermissions?: { allow: string[]; deny: string[] } | null;
projectPermissions?: { allow: string[]; deny: string[] } | null;
effectivePermissions?: { allow: string[]; deny: string[] } | null;
activeProfile?: 'strict' | 'development' | 'custom' | null;
hasProjectConfig?: boolean;
availableProfiles?: Array<{
id: string;
name: string;
description: string;
permissions: { allow: string[]; deny: string[] };
}>;
error?: string;
}> =>
this.get(
`/api/setup/cursor-permissions${projectPath ? `?projectPath=${encodeURIComponent(projectPath)}` : ''}`
),
applyCursorPermissionProfile: (
profileId: 'strict' | 'development',
scope: 'global' | 'project',
projectPath?: string
): Promise<{
success: boolean;
message?: string;
scope?: string;
profileId?: string;
error?: string;
}> => this.post('/api/setup/cursor-permissions/profile', { profileId, scope, projectPath }),
setCursorCustomPermissions: (
projectPath: string,
permissions: { allow: string[]; deny: string[] }
): Promise<{
success: boolean;
message?: string;
permissions?: { allow: string[]; deny: string[] };
error?: string;
}> => this.post('/api/setup/cursor-permissions/custom', { projectPath, permissions }),
deleteCursorProjectPermissions: (
projectPath: string
): Promise<{
success: boolean;
message?: string;
error?: string;
}> =>
this.httpDelete(
`/api/setup/cursor-permissions?projectPath=${encodeURIComponent(projectPath)}`
),
getCursorExampleConfig: (
profileId?: 'strict' | 'development'
): Promise<{
success: boolean;
profileId?: string;
config?: string;
error?: string;
}> =>
this.get(
`/api/setup/cursor-permissions/example${profileId ? `?profileId=${profileId}` : ''}`
),
onInstallProgress: (callback: (progress: unknown) => void) => {
return this.subscribeToEvent('agent:stream', callback);
},