Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compression] Preserve type declarations (critical for LLM context) while allowing function compression #359

Open
FlatMapIO opened this issue Feb 16, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@FlatMapIO
Copy link

Type declarations are structural anchors for LLMs to understand code relationships, whereas function bodies can be safely compressed.

@yamadashy
Copy link
Owner

Hi, @FlatMapIO !
Thank you for feedback!

Indeed, currently the interface and other type definitions are reduced to just the name line, which may be too aggressive in terms of information reduction.
It would be better to preserve all interface, type, and class properties and methods (excluding implementations) - essentially maintaining the same level of information as a d.ts file.

I will look into implementing this change.

@yamadashy yamadashy added the enhancement New feature or request label Feb 16, 2025
@raptium
Copy link

raptium commented Feb 17, 2025

I suggest also preserving documentation comments (docstrings in Python, JSDoc in JavaScript, etc.) along with type declarations. Documentation often contains crucial information about method usage, parameters, and return values that helps LLMs understand the code's purpose and behavior.

If documentation preservation impacts file size significantly, perhaps this could be implemented as a configurable option.

@yamadashy yamadashy pinned this issue Feb 17, 2025
@yamadashy
Copy link
Owner

@raptium
Indeed, I completely agree with you.

When considering what information makes code analysis easier, comments that explain the "Why" are essential.

Since we have the --remove-comments option, users can utilize it if they don't need the comments in their output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants