MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / writePermissionsEntry

Function writePermissionsEntry

src/installer/targets/claude.ts:398–418  ·  view source on GitHub ↗
(loc: Location)

Source from the content-addressed store, hash-verified

396}
397
398export 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` —

Callers 2

writePermissionsFunction · 0.90
installMethod · 0.85

Calls 5

readJsonFileFunction · 0.90
getCodeGraphPermissionsFunction · 0.90
jsonDeepEqualFunction · 0.90
writeJsonFileFunction · 0.90
settingsJsonPathFunction · 0.70

Tested by

no test coverage detected