Add __main__ entry and logging improvements#3
Merged
speakman merged 1 commit intoJun 11, 2025
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a main module to allow execution via “python -m llmcontext”, swaps print statements for logging calls, and warns when generated context might exceed 1M tokens.
- Enable CLI invocation with a dedicated main module
- Replace direct print calls with logging in favor of verbosity control
- Update version and changelog accordingly
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_metadata.py | Updated CLI invocation to use the new main module interface |
| llmcontext/llmcontext.py | Replaced several print calls with logging improvements |
| llmcontext/main.py | Added entry point to support “python -m llmcontext” |
| llmcontext/init.py | Bumped version to 0.1.1 |
| CHANGELOG.md | Documented all new changes in this version update |
Comments suppressed due to low confidence (1)
llmcontext/llmcontext.py:440
- Consider using logger.warning instead of logger.info here (and similarly in subsequent exception handling blocks) to better reflect the severity of file access errors.
logger.info("Warning: Could not access/process file %s: %s", filepath_rel_posix, e)
| @@ -531,19 +546,27 @@ def main(): | |||
| root_dir_abs, args.exclude, output_file_abs_path, args.verbose | |||
| ) | |||
|
|
|||
There was a problem hiding this comment.
The current token estimate is based on splitting the output text by whitespace. Consider documenting that this is an approximation of token count for LLM context purposes.
Suggested change
| # Approximate token count based on splitting the text by whitespace. | |
| # Note: This does not reflect the actual tokenization process used by LLMs, | |
| # which may result in a different token count due to subword tokenization and special characters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__main__module to allowpython -m llmcontextloggingTesting
pytest -qpython -m llmcontext --versionhttps://chatgpt.com/codex/tasks/task_e_68496b337ef0832b8c4bd6baa9a9b279