Skip to content

Conversation

@achitJ
Copy link
Collaborator

@achitJ achitJ commented Jan 28, 2026

Summary

Add runtime APIs to register and reset custom quote header and signature regex patterns to support more email formats (APP-9854). Fix handling of custom regexes without capture groups and rename the package to @clearfeed-ai/email-reply-parser.

  • New Features

    • New methods: addQuoteHeaderRegex(es), addSignatureRegex(es), resetQuoteHeaderRegexes(), resetSignatureRegexes().
    • Methods support chaining; patterns are applied globally across parses.
    • README updated with examples; tests added for custom patterns.
  • Migration

    • Update imports: email-reply-parser → @clearfeed-ai/email-reply-parser.

Test Cases

All the tests ran successfully by running npm run test

image

@gemini-code-assist
Copy link

Summary of Changes

Hello @achitJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the email-reply-parser library by adding support for custom regex patterns for identifying quote headers and signatures. This allows users to adapt the parser to handle various email formats not covered by the default patterns. The changes also include new methods for managing these custom regexes and a bug fix for regexes without capture groups. The README has been updated with documentation for the new features.

Highlights

  • Custom Regex Support: Introduces the ability to add custom regex patterns for quote headers and signatures at runtime, allowing for more flexible email parsing.
  • New Methods: Adds methods for adding, adding multiple, and resetting quote header and signature regexes: addQuoteHeaderRegex(), addQuoteHeaderRegexes(), addSignatureRegex(), addSignatureRegexes(), resetQuoteHeaderRegexes(), and resetSignatureRegexes().
  • Method Chaining: Enables method chaining for custom regex methods, providing a more convenient way to configure the parser.
  • Bug Fix: Fixes an issue where custom regexes without capture groups would cause errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature for adding custom regexes to the email parser, along with comprehensive tests. The implementation is mostly solid, but there are a few important issues to address. There's a critical issue with package versioning where a breaking change (package rename) is not reflected with a major version bump. Additionally, the tests lack isolation, which could lead to flaky results. I've also included some medium-severity suggestions to improve documentation accuracy, API consistency, and code quality. Overall, great work on adding this extensibility.

@achitJ
Copy link
Collaborator Author

achitJ commented Jan 28, 2026

Test log:

achitj@pop-os:~/ClearFeed/email-reply-parser$ npm run test

> @clearfeed-ai/email-reply-parser@2.4.0 test
> npm run unit && npm run lint


> @clearfeed-ai/email-reply-parser@2.4.0 unit
> node ./node_modules/nodeunit/bin/nodeunit test/test.js


test.js
✔ test_addQuoteHeaderRegexes_multiple_patterns
✔ test_addQuoteHeaderRegexes_single_pattern
✔ test_addSignatureRegexes_multiple_patterns
✔ test_addSignatureRegexes_single_pattern
✔ test_case_insensitive_custom_signature
✔ test_complex_body_with_only_one_fragment
✔ test_complex_custom_quote_header_pattern
✔ test_custom_regex_without_capture_group
✔ test_custom_regexes_work_with_default_patterns
✔ test_deals_with_multiline_reply_headers
✔ test_email_22
✔ test_email_23
✔ test_email_24
✔ test_email_25
✔ test_email_26
✔ test_email_da_into_italian
✔ test_email_emoji
✔ test_email_en_multiline_2
✔ test_email_finnish
✔ test_email_fr_2
✔ test_email_fr_multiline
✔ test_email_german
✔ test_email_german_2
✔ test_email_german_3
✔ test_email_german_outlook
✔ test_email_gmail
✔ test_email_gmail_no
✔ test_email_header_polish
✔ test_email_header_polish_with_date_in_iso8601
✔ test_email_header_polish_with_dnia_and_napisala
✔ test_email_italian
✔ test_email_not_a_signature
✔ test_email_not_a_signature_2
✔ test_email_original_message
✔ test_email_original_message_2
✔ test_email_original_message_danish_dash
✔ test_email_original_message_french_dash
✔ test_email_outlook
✔ test_email_outlook_en
✔ test_email_portuguese
✔ test_email_russian
✔ test_email_sent_from_my
✔ test_email_square_brackets
✔ test_email_whitespace_before_header
✔ test_email_with_correct_signature
✔ test_email_with_dutch
✔ test_email_with_hotmail
✔ test_email_with_italian
✔ test_email_with_signature
✔ test_method_chaining_with_custom_regexes
✔ test_one_is_not_one
✔ test_parseReplied_extracts_quoted_text
✔ test_parseReplied_with_multiple_quotes
✔ test_parseReply_extracts_visible_text
✔ test_parseReply_with_quote_header
✔ test_parseReply_with_signature
✔ test_reads_bottom_post
✔ test_reads_email_with_signature_with_no_empty_line_above
✔ test_reads_simple_body
✔ test_reads_top_post
✔ test_recognizes_data_string_above_quote
✔ test_resetQuoteHeaderRegexes_to_defaults
✔ test_resetSignatureRegexes_to_defaults
✔ test_sent_from
✔ test_tricky_code_block
✔ test_tricky_double_signature
✔ test_tricky_forward_header
✔ test_tricky_from_in_body
✔ test_tricky_html_entities
✔ test_tricky_inline_reply
✔ test_tricky_long_quote_header
✔ test_tricky_mixed_languages
✔ test_tricky_multiple_dashes
✔ test_tricky_nested_quotes
✔ test_tricky_no_space_after_header
✔ test_tricky_on_false_positive
✔ test_tricky_original_message_variations
✔ test_tricky_quote_without_header
✔ test_tricky_regards_in_sentence
✔ test_tricky_sent_from_in_content
✔ test_tricky_special_chars_in_name
✔ test_tricky_timestamp_variations
✔ test_tricky_unicode_signatures
✔ test_tricky_url_with_wrote
✔ text_email_ios_outlook
✔ text_email_ios_outlook_fr
✔ text_email_msn
✔ text_email_regards
✔ text_email_reply_header
✔ text_email_zoho

OK: 179 assertions (127ms)

> @clearfeed-ai/email-reply-parser@2.4.0 lint
> eslint .

@achitJ achitJ marked this pull request as ready for review January 28, 2026 11:08
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="README.md">

<violation number="1" location="README.md:171">
P2: Creating additional `EmailReplyParser` instances does not isolate custom regexes—the RegexList is a singleton—so the README’s new guidance to “consider creating separate parser instances” is incorrect and will mislead users.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

.read(emailContent);
```

**Note:** Custom patterns are added globally and will affect all subsequent parsing operations. If you're using this library in a multi-tenant environment, consider creating separate parser instances or resetting patterns between operations.
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Creating additional EmailReplyParser instances does not isolate custom regexes—the RegexList is a singleton—so the README’s new guidance to “consider creating separate parser instances” is incorrect and will mislead users.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 171:

<comment>Creating additional `EmailReplyParser` instances does not isolate custom regexes—the RegexList is a singleton—so the README’s new guidance to “consider creating separate parser instances” is incorrect and will mislead users.</comment>

<file context>
@@ -91,6 +91,85 @@ console.log(parser.parseReply(emailContent));
+  .read(emailContent);
+```
+
+**Note:** Custom patterns are added globally and will affect all subsequent parsing operations. If you're using this library in a multi-tenant environment, consider creating separate parser instances or resetting patterns between operations.
+
 ## Contributing
</file context>
Suggested change
**Note:** Custom patterns are added globally and will affect all subsequent parsing operations. If you're using this library in a multi-tenant environment, consider creating separate parser instances or resetting patterns between operations.
**Note:** Custom patterns are added globally and will affect all subsequent parsing operations. In multi-tenant environments, reset the patterns between tenants or avoid registering tenant-specific patterns globally.
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants