Skip to content

fix(file): Replace strip-comments with @repomix/strip-comments#1009

Merged
yamadashy merged 2 commits intomainfrom
fix/use-repomix-strip-comments
Dec 16, 2025
Merged

fix(file): Replace strip-comments with @repomix/strip-comments#1009
yamadashy merged 2 commits intomainfrom
fix/use-repomix-strip-comments

Conversation

@yamadashy
Copy link
Copy Markdown
Owner

Summary

Replace the original strip-comments package with @repomix/strip-comments, a fork with enhanced language support and bug fixes.

Bug Fix

Improvements in @repomix/strip-comments

  • Go: Preserves compiler directives (//go:build, //go:generate, //go:embed, etc.)
  • C++: Properly removes document comments (///)
  • Python: Correctly handles both """ and ''' docstrings, and hash comments in strings

Refactoring

  • Removes custom GoManipulator, PythonManipulator, and CppManipulator implementations (~230 lines removed)
  • Uses the improved library support instead of maintaining custom parsers

Note

The preserveNewlines option keeps newlines for line number preservation, so docstrings/comments are replaced with empty lines rather than being fully removed.

Checklist

  • Run npm run test
  • Run npm run lint

Replace the original strip-comments package with @repomix/strip-comments,
which provides enhanced support for:
- Go directives (//go:build, //go:generate, etc.)
- C++ document comments (///)
- Python docstrings (""" and ''') and hash comments

This removes the custom GoManipulator, PythonManipulator, and CppManipulator
implementations in favor of the improved library support.

Note: preserveNewlines option keeps newlines for line number preservation,
so docstrings are replaced with empty lines rather than being fully removed.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 14, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Migrated from the strip-comments library to @repomix/strip-comments and consolidated file comment-stripping across multiple language types. Removed specialized language-specific manipulator classes (CppManipulator, GoManipulator, PythonManipulator) in favor of a unified StripCommentsManipulator approach, expanded file extension support, and added a removeEmptyLines method to the FileManipulator interface.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
Replaced strip-comments (^2.0.1) with @repomix/strip-comments (^2.4.1)
File Manipulation Consolidation
src/core/file/fileManipulate.ts
Switched import to use new comment-stripping library; added removeEmptyLines() method to FileManipulator interface; removed CppManipulator, GoManipulator, and PythonManipulator classes; unified language-specific handling via StripCommentsManipulator with language codes; expanded file extension mappings (.scss, .sh, .sol, .sql, .swift, .ts, .tsx, .xml, .yaml, .yml, etc.); retained CompositeManipulator for multi-manipulator scenarios
Test Comments
tests/core/file/fileManipulate.test.ts
Added inline documentation comments in test cases (no functional changes)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify that StripCommentsManipulator with language codes produces equivalent output to the removed specialized manipulators, particularly for C++ (.cpp, .hpp, .cc, .cxx), Go, and Python files
  • Confirm all previously-mapped file extensions are still handled and the new extensions (e.g., .scss, .sh, .sol, .ts, .tsx) are correctly mapped
  • Check that the new removeEmptyLines() interface method is implemented across all FileManipulator implementations

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing the strip-comments package with @repomix/strip-comments.
Description check ✅ Passed The description provides comprehensive coverage of changes, improvements, and refactoring, and includes the required checklist items (both marked as completed).
Linked Issues check ✅ Passed The PR successfully addresses issue #975 by replacing the problematic strip-comments library with @repomix/strip-comments to resolve hanging on large minified files.
Out of Scope Changes check ✅ Passed All changes are directly related to the library replacement and refactoring goals; no unrelated or out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @yamadashy, 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 refactors the comment stripping mechanism by migrating from the original strip-comments package to the more robust @repomix/strip-comments fork. This strategic change not only addresses a critical performance bug related to large file processing but also significantly enhances language-specific comment handling for Go, C++, and Python. By leveraging the new library's built-in capabilities, the codebase is streamlined, reducing the need for custom manipulator implementations and improving the overall accuracy of comment removal while preserving line structure.

Highlights

  • Dependency Update: The strip-comments package has been replaced with @repomix/strip-comments, a fork offering enhanced capabilities.
  • Bug Fix: This change resolves a previously reported issue (bug(cli): --remove-comments hangs on large minified files with extremely long lines #975) where the removeComments function would hang when processing large files.
  • Enhanced Language Support: The new library provides improved comment stripping for Go (preserving compiler directives), C++ (correctly removing /// document comments), and Python (accurately handling '''/""" docstrings and hash comments within strings).
  • Code Refactoring: Approximately 230 lines of custom GoManipulator, PythonManipulator, and CppManipulator implementations have been removed, as their functionality is now handled by the improved @repomix/strip-comments library.
  • Newline Preservation: The preserveNewlines option is now consistently used, ensuring that removed comments and docstrings are replaced with empty lines to maintain original line numbering, rather than being fully deleted.
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.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.24%. Comparing base (b7f960e) to head (6e19fd8).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1009      +/-   ##
==========================================
- Coverage   90.36%   90.24%   -0.13%     
==========================================
  Files         120      120              
  Lines        9241     9017     -224     
  Branches     1698     1623      -75     
==========================================
- Hits         8351     8137     -214     
+ Misses        890      880      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 14, 2025

PR Review: fix(file): Replace strip-comments with @repomix/strip-comments

Summary

This PR replaces the original strip-comments package with @repomix/strip-comments, a fork with enhanced language support. The change removes ~230 lines of custom manipulator code (Go, Python, C++) while fixing a critical hanging issue (#975) and improving language support.

Code Quality ✅

Positive aspects:

  • Clean reduction of code complexity by removing custom GoManipulator, PythonManipulator, and CppManipulator classes
  • Consistent use of StripCommentsManipulator across all languages
  • Tests updated to reflect new behavior with preserveNewlines
  • Follows existing code patterns in the codebase

Minor observations:

  • The rtrimLines utility and BaseManipulator remain well-structured
  • CompositeManipulator for Vue/Svelte files is preserved appropriately

Bug Fix Verification ✅

The PR addresses issue #975 (hanging on large files with removeComments). The switch to @repomix/strip-comments should resolve this by using an improved library implementation.

Test Coverage ✅

  • Existing tests are updated to reflect the new behavior where preserveNewlines: true keeps newlines for line number preservation
  • Tests cover Go directives, Python docstrings/f-strings, C++ triple-slash comments
  • Comments added to clarify the newline preservation behavior
Detailed Test Analysis

The test updates add extra blank lines in expected outputs because the new library preserves newlines when removing multi-line comments/docstrings. This is intentional behavior for maintaining line number correspondence between original and processed files.

Key test scenarios covered:

  • Python: docstrings, hash comments, f-strings, nested quotes
  • Go: directives (//go:build, //go:generate), string literals, raw strings
  • C++: triple-slash documentation comments (///)

Security Considerations ✅

  • No security concerns with this change
  • The new package is from the @repomix namespace, indicating it's a maintained fork
  • Package is published on npm with proper versioning

Potential Risks & Mitigations

Risk Likelihood Mitigation
Behavioral differences in edge cases Low Comprehensive test suite covers major scenarios
New package maintenance burden Low Package is under @repomix namespace (same maintainer)
Regression in comment removal for unsupported languages Low Most languages use the same underlying parser
Premortem Analysis

Potential failure scenarios:

  1. Edge case differences: Some obscure syntax patterns may behave differently between the old custom implementations and the new library. The test suite covers major cases, but real-world code may reveal edge cases.

  2. Unicode handling: If the new library handles Unicode differently in comments (e.g., comments with non-ASCII characters), some users may see unexpected behavior.

  3. Language-specific quirks: Languages like Python have complex string/comment syntax. While tests pass, unusual Python code (decorators with string interpolation, etc.) could expose differences.

Recommended mitigations:

  • Monitor issues after release for any reported regressions
  • Consider adding a few more edge case tests if any user reports surface

Verdict: Approve

This is a well-executed improvement that:

  1. Fixes a blocking issue (bug(cli): --remove-comments hangs on large minified files with extremely long lines #975)
  2. Reduces maintenance burden by removing 230+ lines of custom code
  3. Improves language support (Go directives, C++ triple-slash, Python docstrings)
  4. Has adequate test coverage

The PR follows the project's coding guidelines and commit message conventions.


Review by Claude Code

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Dec 14, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6e19fd8
Status: ✅  Deploy successful!
Preview URL: https://15e6361f.repomix.pages.dev
Branch Preview URL: https://fix-use-repomix-strip-commen.repomix.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@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 is an excellent pull request that significantly simplifies the codebase by replacing approximately 230 lines of custom, complex comment-stripping logic with the @repomix/strip-comments library. This change improves maintainability, leverages a more capable fork for better language support (C++, Go, Python), and fixes a critical bug (#975) related to processing large files. The refactoring and corresponding test updates are well-executed. Great work!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/core/file/fileManipulate.ts (1)

67-89: Pragmatic language fallbacks work but merit a brief comment.

Using 'c' for Dart/Kotlin/Rust/Solidity and 'perl' for shell/YAML leverages compatible comment syntax. Consider adding a brief inline comment explaining these fallbacks for future maintainers:

+  // Dart, Kotlin, Rust, Solidity use C-style comments (// and /* */)
   '.dart': new StripCommentsManipulator('c'),
   ...
+  // Shell and YAML use # for comments, similar to Perl
   '.sh': new StripCommentsManipulator('perl'),
package.json (1)

107-107: Remove the redundant @types/strip-comments devDependency.

@repomix/strip-comments (v2.4.1) includes its own TypeScript declarations via index.d.ts, making @types/strip-comments unnecessary.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7f960e and cdae79d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/core/file/fileManipulate.ts (2 hunks)
  • tests/core/file/fileManipulate.test.ts (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Test (windows-latest, 24.x)
  • GitHub Check: Test (windows-latest, 20.x)
  • GitHub Check: Test (windows-latest, 22.x)
  • GitHub Check: Test (windows-latest, 25.x)
  • GitHub Check: Test (macos-latest, 25.x)
  • GitHub Check: Build and run (windows-latest, 20.x)
  • GitHub Check: Build and run with Bun (windows-latest, latest)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
package.json (1)

78-78: LGTM on the dependency change.

The migration to @repomix/strip-comments addresses the hanging issue on large files (issue #975) and provides better language support for Go, C++, and Python.

tests/core/file/fileManipulate.test.ts (1)

1-1040: Comprehensive test coverage for the comment stripping migration.

The test suite thoroughly covers:

  • Language-specific comment syntax (C-style, Python, Ruby, SQL, YAML)
  • Go compiler directives preservation (//go:build, //go:generate)
  • C++ triple-slash documentation comments
  • Python edge cases (f-strings, nested quotes, docstrings vs string literals)
  • Composite file types (Vue, Svelte)

The inline comments clarifying preserveNewlines behavior improve test readability.

src/core/file/fileManipulate.ts (3)

1-6: Clean interface and import migration.

The switch to @repomix/strip-comments and the FileManipulator interface are well-structured.


36-42: Good use of preserveNewlines for line number preservation.

This ensures that after comment removal, the line numbers in error messages or debugging remain accurate, which aligns with the PR objectives.


91-100: Composite manipulator correctly handles multi-language SFC files.

Chaining HTML, CSS, and JavaScript strippers ensures all comment types are removed from Vue and Svelte single-file components.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 14, 2025

PR Review: fix(file): Replace strip-comments with @repomix/strip-comments

Overall Assessment: ✅ Approve

This is a well-executed PR that successfully migrates to @repomix/strip-comments while removing ~230 lines of custom manipulator code. The changes address issue #975 and improve language support across Go, C++, and Python.

New Observations

Since previous reviews have covered the main aspects, here's one remaining item:

📦 Minor: Redundant devDependency

@types/strip-comments in devDependencies (line 107)

The @repomix/strip-comments package (v2.4.2) includes its own TypeScript declarations via index.d.ts, making @types/strip-comments unnecessary. This was noted by CodeRabbit but appears to still be present.

Consider removing it in a follow-up:

npm uninstall @types/strip-comments

This is a minor cleanup item and doesn't block merge.

Premortem Summary

Risk Likelihood Impact Notes
Edge case differences in comment parsing Low Low Test suite is comprehensive
Unicode handling differences Low Low Most users use ASCII comments
Dependency maintenance Very Low Low Package is under @repomix namespace

The PR is ready for merge. All tests pass, code coverage is maintained, and the implementation is clean.


🤖 Review by Claude Code

@yamadashy yamadashy merged commit d61740e into main Dec 16, 2025
54 checks passed
@yamadashy yamadashy deleted the fix/use-repomix-strip-comments branch December 16, 2025 13:12
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.

bug(cli): --remove-comments hangs on large minified files with extremely long lines

1 participant