Skip to content

Commit

Permalink
feat: Update version to 0.1.5 and improve output formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewcasale committed Dec 14, 2024
1 parent 1cfb62e commit 7147eda
Show file tree
Hide file tree
Showing 9 changed files with 5,488 additions and 200 deletions.
30 changes: 24 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2024-12-14
## [0.1.5] - 2024-12-14

### Changed
- Major version bump to reflect stable package structure
- Renamed src directory to repominify for better package organization
- Updated package configuration to match new directory structure
### Added
- Enhanced code context extraction:
- Function and method signatures with full parameter lists
- Complete docstrings with parameter descriptions
- Constants and their values
- Environment variables and configurations
- Module-level documentation
- Import relationships
- Class hierarchies and dependencies
- Improved text representation format for better LLM context
- More detailed output file documentation

### Fixed
- File count statistics in output file comparison
- More accurate comparison between input and output files

## [0.1.4] - 2024-12-14

### Fixed
- CLI entry point path to use correct module location
- Package structure for proper imports

## [0.1.3] - 2024-12-14

Expand Down Expand Up @@ -51,7 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Restructured project to use src/ directory layout
- Updated package metadata and documentation

[1.3.0]: https://github.com/mikewcasale/repominify/compare/v0.1.3...v1.3.0
[0.1.5]: https://github.com/mikewcasale/repominify/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/mikewcasale/repominify/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/mikewcasale/repominify/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/mikewcasale/repominify/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/mikewcasale/repominify/compare/v0.1.0...v0.1.1
Expand Down
53 changes: 35 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ repominify helps you provide detailed context about your codebase to LLMs withou
- **Code Analysis**
- Parses and analyzes code structure
- Extracts imports, classes, and functions
- Captures function signatures and docstrings
- Identifies and extracts constants and environment variables
- Builds dependency graphs
- Performance optimized for large codebases

Expand All @@ -32,6 +34,15 @@ repominify helps you provide detailed context about your codebase to LLMs withou
- YAML for statistics
- Text for human-readable analysis

- **Rich Code Context**
- Complete function/method signatures
- Full docstrings with parameter descriptions
- Constants and their values
- Environment variables and configurations
- Module-level documentation
- Import relationships
- Class hierarchies and dependencies

- **Size Optimization**
- Generates minified code structure representation
- Provides detailed size reduction statistics
Expand Down Expand Up @@ -112,27 +123,42 @@ if ensure_dependencies():
Analysis Complete!
📊 File Stats:
────────────────
Total Files: 18
Total Chars: 1,091,801
Total Tokens: 354,159
Output: repomix-output.txt
Total Files: 29
Total Chars: 143,887
Total Tokens: 14,752
Output: input.txt
Security: ✔ No suspicious files detected
📊 File Stats:
────────────────
Total Files: 18
Total Chars: 245,123
Total Tokens: 89,456
Total Files: 29
Total Chars: 26,254
Total Tokens: 3,254
Output: code_graph.txt
Security: ✔ No suspicious files detected
📈 Comparison:
────────────────
Char Reduction: 77.5%
Token Reduction: 74.7%
Char Reduction: 81.8%
Token Reduction: 77.9%
Security Notes: ✔ No issues found
```

## Output Files

When you run repominify, it generates several files in your output directory:

- `code_graph.graphml`: Graph representation in GraphML format
- `code_graph.json`: Graph data in JSON format for web visualization
- `graph_statistics.yaml`: Statistical analysis of the codebase
- `code_graph.txt`: Human-readable text representation including:
- Module structure and dependencies
- Function signatures and docstrings
- Class definitions and hierarchies
- Constants and their values
- Environment variables
- Import relationships

## Project Structure

```
Expand Down Expand Up @@ -160,15 +186,6 @@ repominify/
└── README.md # This file
```

## Output Files

When you run repominify, it generates several files in your output directory:

- `code_graph.graphml`: Graph representation in GraphML format
- `code_graph.json`: Graph data in JSON format for web visualization
- `graph_statistics.yaml`: Statistical analysis of the codebase
- `code_graph.txt`: Human-readable text representation

## Performance

repominify is designed to handle large codebases efficiently:
Expand Down
2 changes: 1 addition & 1 deletion repominify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
repominify - Optimize codebase representations for LLMs
"""

__version__ = "0.1.3"
__version__ = "0.1.5"
__author__ = "Mike Casale"
__email__ = "[email protected]"

Expand Down
80 changes: 38 additions & 42 deletions repominify/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,41 @@
EXIT_PARSE_ERROR: Final[int] = 4
EXIT_GRAPH_ERROR: Final[int] = 5


@dataclass
class CliOptions:
"""Container for command-line options.
Attributes:
input_file: Path to the Repomix output file
output_dir: Directory for analysis output files
debug: Whether to enable debug logging
Example:
>>> opts = CliOptions(Path("input.txt"), Path("output"), debug=True)
>>> print(opts.input_file)
input.txt
"""

# Required fields
input_file: Path
output_dir: Path

# Optional fields with defaults
debug: bool = False


def parse_args() -> CliOptions:
"""Parse command-line arguments.
Returns:
CliOptions containing validated arguments
Example:
>>> args = parse_args()
>>> print(f"Processing {args.input_file}")
Processing repomix-output.txt
Note:
Uses argparse's built-in help and error handling
"""
Expand All @@ -94,42 +97,34 @@ def parse_args() -> CliOptions:
# Enable debug logging
repo-minify repomix-output.txt --debug
"""
""",
)
parser.add_argument("input_file", type=Path, help="Path to the Repomix output file")
parser.add_argument(
"input_file",
type=Path,
help="Path to the Repomix output file"
)
parser.add_argument(
"-o", "--output-dir",
"-o",
"--output-dir",
type=Path,
default=Path("repo_minify_output"),
help="Output directory for analysis files"
)
parser.add_argument(
"--debug",
action="store_true",
help="Enable debug logging"
help="Output directory for analysis files",
)

parser.add_argument("--debug", action="store_true", help="Enable debug logging")

args = parser.parse_args()
return CliOptions(
input_file=args.input_file,
output_dir=args.output_dir,
debug=args.debug
input_file=args.input_file, output_dir=args.output_dir, debug=args.debug
)


def handle_error(error: Exception, debug: bool) -> NoReturn:
"""Handle errors with appropriate messaging and logging.
Args:
error: The exception to handle
debug: Whether debug mode is enabled
Note:
Always exits the program with an appropriate status code
Exit Codes:
1: General error
2: File not found
Expand All @@ -155,68 +150,69 @@ def handle_error(error: Exception, debug: bool) -> NoReturn:
raise
sys.exit(EXIT_GENERAL_ERROR)


def main() -> int:
"""Main entry point for the repo-minify CLI.
Returns:
Exit code (0 for success, non-zero for error)
Exit Codes:
0: Success
1: General error
2: File not found
3: Permission denied
4: Parse error
5: Graph build error
Example:
>>> sys.exit(main()) # Run the CLI
"""
try:
# Parse arguments
args = parse_args()

# Configure logging
configure_logging(debug=args.debug)

# Check dependencies
if not ensure_dependencies():
print("Failed to verify required dependencies", file=sys.stderr)
logger.debug("Dependency check failed")
return EXIT_GENERAL_ERROR

# Create output directory
args.output_dir.mkdir(parents=True, exist_ok=True)

# Create graph builder
builder = CodeGraphBuilder(debug=args.debug)

# Parse input file
logger.info(f"Parsing {args.input_file}")
file_entries = builder.parser.parse_file(str(args.input_file))
print(f"Found {len(file_entries)} files to analyze")

# Build graph
logger.info("Building dependency graph")
graph = builder.build_graph(file_entries)
print(f"Built graph with {graph.number_of_nodes()} nodes")

# Save outputs and get comparison
logger.info(f"Saving outputs to {args.output_dir}")
_, comparison = builder.save_graph(
str(args.output_dir),
input_file=str(args.input_file)
str(args.output_dir), input_file=str(args.input_file)
)

if comparison:
print("\nAnalysis Complete!")
print(comparison)

print(f"\nOutput files saved to: {args.output_dir}/")
return EXIT_SUCCESS

except Exception as e:
handle_error(e, args.debug if 'args' in locals() else False)
handle_error(e, args.debug if "args" in locals() else False)


if __name__ == "__main__":
sys.exit(main())
Loading

0 comments on commit 7147eda

Please sign in to comment.