migrateBypassPermissionsAcceptedToSettings.ts
migrations/migrateBypassPermissionsAcceptedToSettings.ts
41
Lines
1262
Bytes
1
Exports
4
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with shell-safety, permissions. It contains 41 lines, 4 detected imports, and 1 detected exports.
Important relationships
- migrations/migrateAutoUpdatesToSettings.ts
- migrations/migrateEnableAllProjectMcpServersToSettings.ts
- migrations/migrateFennecToOpus.ts
- migrations/migrateLegacyOpusToCurrent.ts
- migrations/migrateOpusToOpus1m.ts
- migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.ts
- migrations/migrateSonnet1mToSonnet45.ts
- migrations/migrateSonnet45ToSonnet46.ts
Detected exports
migrateBypassPermissionsAcceptedToSettings
Keywords
settingsbypasspermissionsmodeacceptedcurrentutilslogeventgetglobalconfigsaveglobalconfigconfiglogerrorhasskipdangerousmodepermissionprompt
Detected imports
src/services/analytics/index.js../utils/config.js../utils/log.js../utils/settings/settings.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { logEvent } from 'src/services/analytics/index.js'
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js'
import { logError } from '../utils/log.js'
import {
hasSkipDangerousModePermissionPrompt,
updateSettingsForSource,
} from '../utils/settings/settings.js'
/**
* Migration: Move bypassPermissionsModeAccepted from global config to settings.json
* as skipDangerousModePermissionPrompt. This is a better home since settings.json
* is the user-configurable settings file.
*/
export function migrateBypassPermissionsAcceptedToSettings(): void {
const globalConfig = getGlobalConfig()
if (!globalConfig.bypassPermissionsModeAccepted) {
return
}
try {
if (!hasSkipDangerousModePermissionPrompt()) {
updateSettingsForSource('userSettings', {
skipDangerousModePermissionPrompt: true,
})
}
logEvent('tengu_migrate_bypass_permissions_accepted', {})
saveGlobalConfig(current => {
if (!('bypassPermissionsModeAccepted' in current)) return current
const { bypassPermissionsModeAccepted: _, ...updatedConfig } = current
return updatedConfig
})
} catch (error) {
logError(
new Error(`Failed to migrate bypass permissions accepted: ${error}`),
)
}
}