MCPcopy Index your code
hub / github.com/codeaashu/claude-code / createReadRuleSuggestion

Function createReadRuleSuggestion

src/utils/permissions/PermissionUpdate.ts:361–389  ·  view source on GitHub ↗
(
  dirPath: string,
  destination: PermissionUpdateDestination = 'session',
)

Source from the content-addressed store, hash-verified

359 * @returns A PermissionUpdate for a Read rule, or undefined for the root directory
360 */
361export function createReadRuleSuggestion(
362 dirPath: string,
363 destination: PermissionUpdateDestination = 'session',
364): PermissionUpdate | undefined {
365 // Convert to POSIX format for pattern matching (handles Windows internally)
366 const pathForPattern = toPosixPath(dirPath)
367
368 // Root directory is too broad to be a reasonable permission target
369 if (pathForPattern === '/') {
370 return undefined
371 }
372
373 // For absolute paths, prepend an extra / to create //path/** pattern
374 const ruleContent = posix.isAbsolute(pathForPattern)
375 ? `/${pathForPattern}/**`
376 : `${pathForPattern}/**`
377
378 return {
379 type: 'addRules',
380 rules: [
381 {
382 toolName: 'Read',
383 ruleContent,
384 },
385 ],
386 behavior: 'allow',
387 destination,
388 }
389}
390

Callers 3

createPathCheckerFunction · 0.85
generateSuggestionsFunction · 0.85

Calls 1

toPosixPathFunction · 0.85

Tested by

no test coverage detected