mergeHookInstructions function
Merge user-supplied custom instructions with hook-provided instructions.
User instructions come first; hook instructions are appended.
Empty strings normalize to null.
Implementation
String? mergeHookInstructions(
String? userInstructions,
String? hookInstructions,
) {
final user = (userInstructions?.isNotEmpty ?? false) ? userInstructions : null;
final hook = (hookInstructions?.isNotEmpty ?? false) ? hookInstructions : null;
if (hook == null) return user;
if (user == null) return hook;
return '$user\n\n$hook';
}