The All Code Aggregator script consolidates all programming-related code files in the current directory into a single full_code.txt file. This is especially useful for providing your entire codebase to AI models for analysis or assistance.
- Directory Tree Generation: Creates an ASCII representation of the directory structure, excluding specified directories.
- Code Aggregation: Combines contents of programming-related files into a master file.
- Customizable Inclusions/Exclusions: Easily specify which files or directories to include or exclude.
- Clone the Repository
Basic usage
python all_code.pySpecify a Directory
python all_code.py -d /path/to/start/directoryCopy Aggregated Content to Clipboard Instead of Writing to File
python all_code.py -cCombine Both Arguments: Specify Directory and Copy to Clipboard
python all_code.py -d /path/to/start/directory -cExclude Specific File Extensions
python all_code.py -X .json,.md,.htmlCombine Multiple Options: Specify Directory, Copy to Clipboard, and Exclude Extensions
python all_code.py -d /path/to/start/directory -c -X .json,.md,.htmlMore options
python all_code.py --help
usage: all_code.py [-h] [-c] [-d DIRECTORY] [-o OUTPUT_FILE] [-i INCLUDE_FILES] [-x EXTENSIONS] [-e EXCLUDE_DIRS]
Aggregate code files into a master file with a directory tree.
options:
-h, --help show this help message and exit
-c, --clipboard Copy the aggregated content to the clipboard instead of writing to a file.
-d, --directory DIRECTORY
Specify the directory to start aggregation from. Defaults to the current working directory.
-o, --output-file OUTPUT_FILE
Name of the output file. Defaults to full_code.txt.
-i, --include-files INCLUDE_FILES
Comma-separated list of files to include. If not provided, all files are included.
-x, --extensions EXTENSIONS
Comma-separated list of programming extensions to use. Replaces the default set if provided.
-e, --exclude-dirs EXCLUDE_DIRS
Comma-separated list of directories to exclude. Replaces the default set if provided.
-X, --exclude-extensions EXCLUDE_EXTENSIONS
Comma-separated list of file extensions to exclude from aggregation.The All Code Aggregator script automatically excludes specific directories and files to streamline the aggregation process and avoid including unnecessary or sensitive information.
The following directories are excluded by default:
venvznode_modules__pycache__.gitdistbuildtempold_filesflask_session
Users can now exclude specific file extensions using the -X or --exclude-extensions argument.
Example:
python all_code.py -X .json,.md,.htmlThis will exclude all .json, .md, and .html files from aggregation.
Purpose: These directories are typically used for virtual environments, dependencies, build artifacts, version control, or temporary files that are not part of the core codebase.
Example Output to full_code.txt
Directory Tree:
all_code/
│ ├── full_code.txt
│ ├── README.md
│ ├── test.py
│ ├── .git/ [EXCLUDED]
│ ├── demo_folder/
│ │ ├── another_file.js
# ======================
# File: test.py
# ======================
def greet(name):
return f"Hello, {name}!"
if __name__ == "__main__":
print(greet("World"))
def farewell(name):
return f"Goodbye, {name}!"
print(farewell("World"))
# ======================
# File: demo_folder\another_file.js
# ======================
// another_file.js
// Function to add two numbers
function add(a, b) {
return a + b;
}
// Function to subtract two numbers
function subtract(a, b) {
return a - b;
}
// Function to multiply two numbers
function multiply(a, b) {
return a * b;
}
// Function to divide two numbers
function divide(a, b) {
if (b === 0) {
throw new Error("Division by zero is not allowed.");
}
return a / b;
}
// Example usage
console.log("Add: " + add(5, 3)); // Output: Add: 8
console.log("Subtract: " + subtract(5, 3)); // Output: Subtract: 2
console.log("Multiply: " + multiply(5, 3)); // Output: Multiply: 15
console.log("Divide: " + divide(5, 3)); // Output: Divide: 1.6666666666666667
If you want to test the script, run the following command.
python test_all_code.pyAs of the current commit, only the command line args and their effects were tested, but more tests can be added in the future.
