registerAll static method

void registerAll(
  1. HookExecutor executor, {
  2. bool isPermitted(
    1. String,
    2. Map<String, dynamic>
    )?,
  3. bool isInSandbox(
    1. String
    )?,
  4. List<String>? allowedPaths,
  5. int maxCallsPerMinute = 60,
  6. void logEntry(
    1. String
    )?,
  7. void onUsage(
    1. int,
    2. int,
    3. double
    )?,
  8. Future<void> writeBackup(
    1. String,
    2. String
    )?,
  9. List<String>? protectedBranches,
  10. void onSecretWarning(
    1. String
    )?,
})

Register all built-in hooks with the given executor.

This is a convenience method for initialization. The config map allows customization of individual hooks.

Implementation

static void registerAll(
  HookExecutor executor, {
  bool Function(String, Map<String, dynamic>)? isPermitted,
  bool Function(String)? isInSandbox,
  List<String>? allowedPaths,
  int maxCallsPerMinute = 60,
  void Function(String)? logEntry,
  void Function(int, int, double)? onUsage,
  Future<void> Function(String, String)? writeBackup,
  List<String>? protectedBranches,
  void Function(String)? onSecretWarning,
}) {
  if (isPermitted != null) {
    executor.register(permissionCheckHook(isPermitted: isPermitted));
  }

  if (isInSandbox != null) {
    executor.register(
      sandboxEnforcementHook(
        allowedPaths: allowedPaths ?? [],
        isInSandbox: isInSandbox,
      ),
    );
  }

  executor.register(rateLimitHook(maxCallsPerMinute: maxCallsPerMinute));

  if (logEntry != null) {
    executor.register(auditLogHook(logEntry: logEntry));
  }

  if (onUsage != null) {
    executor.register(costTrackingHook(onUsage: onUsage));
  }

  if (writeBackup != null) {
    executor.register(fileBackupHook(writeBackup: writeBackup));
  }

  executor.register(
    gitSafetyHook(protectedBranches: protectedBranches ?? ['main', 'master']),
  );

  executor.register(secretDetectionHook(onWarning: onSecretWarning));
}