(loc: Location)
| 396 | } |
| 397 | |
| 398 | export function writePermissionsEntry(loc: Location): WriteResult['files'][number] { |
| 399 | const file = settingsJsonPath(loc); |
| 400 | const settings = readJsonFile(file); |
| 401 | const created = !fs.existsSync(file); |
| 402 | |
| 403 | if (!settings.permissions) settings.permissions = {}; |
| 404 | if (!Array.isArray(settings.permissions.allow)) settings.permissions.allow = []; |
| 405 | |
| 406 | const want = getCodeGraphPermissions(); |
| 407 | const before = [...settings.permissions.allow]; |
| 408 | for (const perm of want) { |
| 409 | if (!settings.permissions.allow.includes(perm)) { |
| 410 | settings.permissions.allow.push(perm); |
| 411 | } |
| 412 | } |
| 413 | if (jsonDeepEqual(before, settings.permissions.allow) && !created) { |
| 414 | return { path: file, action: 'unchanged' }; |
| 415 | } |
| 416 | writeJsonFile(file, settings); |
| 417 | return { path: file, action: created ? 'created' : 'updated' }; |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Write the front-load `UserPromptSubmit` hook into Claude `settings.json` — |
no test coverage detected