Require explicit commenter context in openers

This commit is contained in:
jjbrunton committed 2026-08-14 12:50:39 +01:00
1 parent f77157d303
commit 2500f0a23c
4 files changed
+18 -2

No files matched your search

+3 -2
View File
@@ -3,7 +3,7 @@ export interface CommentTargetedOpenerValidation {
reason?: string;
}
const COMMENT_GROUNDING = /\b(?:comment|said|wrote|mentioned|wanted|wanting|wish(?:ed)?|liked the idea|you(?:'d| would) love)\b/i;
const COMMENT_GROUNDING = /\b(?:comment|you (?:said|wrote|mentioned)|i (?:saw|noticed) you|what you (?:said|wrote|mentioned))\b/i;
const RECIPIENT_APPEARANCE_PATTERNS: ReadonlyArray<{ pattern: RegExp; reason: string }> = [
{
@@ -35,7 +35,8 @@ const RECIPIENT_APPEARANCE_PATTERNS: ReadonlyArray<{ pattern: RegExp; reason: st
*/
export function validateCommentTargetedOpener(message: string): CommentTargetedOpenerValidation {
const trimmed = message.trim();
if (!COMMENT_GROUNDING.test(trimmed)) {
const firstSentence = trimmed.split(/[.!?\n]/, 1)[0] ?? '';
if (!COMMENT_GROUNDING.test(firstSentence)) {
return { safe: false, reason: 'does not ground the opener in what the commenter expressed' };
}
for (const rule of RECIPIENT_APPEARANCE_PATTERNS) {