|
| 1 | +# Code2Prompt Manager |
| 2 | + |
| 3 | +A CLI tool to manage file size limits when using [code2prompt](https://github.com/mufeedvh/code2prompt). This tool helps you interactively select which files to exclude from your codebase to keep the output Markdown file under your desired size limit. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +# Install globally |
| 9 | +npm install -g code2prompt-manager |
| 10 | + |
| 11 | +# Or run directly with npx |
| 12 | +npx code2prompt-manager |
| 13 | +``` |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +- Node.js 12 or higher |
| 18 | +- code2prompt must already be installed on your system |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +```bash |
| 23 | +code2prompt-manager [options] |
| 24 | +``` |
| 25 | + |
| 26 | +### Options |
| 27 | + |
| 28 | +- `-l, --limit <size>`: Size limit for the generated MD file in KB (default: 400) |
| 29 | +- `-d, --directory <path>`: Directory to scan (default: current directory) |
| 30 | +- `-e, --extra-exclude <patterns>`: Additional exclude patterns (comma-separated) |
| 31 | +- `-i, --include <patterns>`: Include patterns (comma-separated) |
| 32 | +- `-O, --output-file <file>`: Output file name (default: codebase.md) |
| 33 | +- `-F, --output-format <format>`: Output format: markdown, json, or xml (default: markdown) |
| 34 | +- `--include-priority`: Include files in case of conflict between include and exclude patterns |
| 35 | +- `--full-directory-tree`: List the full directory tree |
| 36 | +- `-c, --encoding <encoding>`: Optional tokenizer to use for token count |
| 37 | +- `--line-numbers`: Add line numbers to the source code |
| 38 | +- `-n, --no-execute`: Only show the command, don't execute it |
| 39 | + |
| 40 | +## How it Works |
| 41 | + |
| 42 | +1. The tool scans your codebase directory |
| 43 | +2. Files and directories are sorted by size (largest first) |
| 44 | +3. An interactive UI lets you select which files to exclude |
| 45 | +4. The tool generates and executes the appropriate code2prompt command |
| 46 | + |
| 47 | +## Example |
| 48 | + |
| 49 | +```bash |
| 50 | +# Basic usage with default options |
| 51 | +code2prompt-manager |
| 52 | + |
| 53 | +# Set a custom size limit (in KB) |
| 54 | +code2prompt-manager --limit 350 |
| 55 | + |
| 56 | +# Specify a custom output file |
| 57 | +code2prompt-manager --output-file my-project.md |
| 58 | + |
| 59 | +# Scan a specific directory and don't execute the command |
| 60 | +code2prompt-manager -d ./my-project -n |
| 61 | + |
| 62 | +# Specify additional files to exclude |
| 63 | +code2prompt-manager -e "*.log,temp/**" |
| 64 | +``` |
| 65 | + |
| 66 | +## Default Excludes |
| 67 | + |
| 68 | +The tool automatically excludes common large directories and files: |
| 69 | + |
| 70 | +- node_modules/** |
| 71 | +- vendor/** |
| 72 | +- .git/** |
| 73 | +- .next/** |
| 74 | +- .husky/** |
| 75 | +- package-lock.json |
| 76 | +- composer.lock |
| 77 | +- yarn.lock |
| 78 | +- dist/** |
| 79 | +- build/** |
| 80 | +- *.min.js |
| 81 | +- *.min.css |
| 82 | + |
| 83 | +You can add or remove excludes through the interactive selection. |
| 84 | + |
| 85 | +## Tips for Reducing File Size |
| 86 | + |
| 87 | +1. Exclude test files and directories |
| 88 | +2. Exclude documentation and example files |
| 89 | +3. Exclude large media files |
| 90 | +4. Focus on the core functionality of your codebase |
| 91 | +5. Exclude third-party libraries and dependencies |
| 92 | + |
| 93 | +## License |
| 94 | + |
| 95 | +MIT |
0 commit comments