2026-02-15 08:55:22 -05:00
#!/bin/bash
2026-03-07 17:08:26 -05:00
# This file is because I am barbaric and don't use things like claude code but when I want to leverage an LLM, I can run this, it concats the code into a single file and then i can throw it into a chat window and give it all the code
2026-02-15 08:55:22 -05:00
# Output file
2026-02-15 12:42:55 -05:00
OUTPUT_FILE = "jormundb-odin-project_context.txt"
2026-02-15 08:55:22 -05:00
# Directories to exclude
2026-02-15 11:17:12 -05:00
EXCLUDE_DIRS = ( "build" "data" ".git" )
2026-02-15 08:55:22 -05:00
# File extensions to include (add more as needed)
2026-02-15 11:45:09 -05:00
INCLUDE_EXTENSIONS = ( "odin" "Makefile" "md" "json" "h" "cc" )
2026-02-15 08:55:22 -05:00
# Special files to include (without extension)
2026-02-15 12:42:55 -05:00
INCLUDE_FILES = ( "Makefile" )
2026-02-15 08:55:22 -05:00
# Clear the output file
> " $OUTPUT_FILE "
# Function to check if directory should be excluded
should_exclude_dir( ) {
local dir = " $1 "
for exclude in " ${ EXCLUDE_DIRS [@] } " ; do
if [ [ " $dir " = = *" / $exclude " * ] ] || [ [ " $dir " = = " $exclude " * ] ] ; then
return 0
fi
done
return 1
}
# Function to check if file should be included
should_include_file( ) {
local file = " $1 "
local basename = $( basename " $file " )
# Check if it's in the special files list
for special in " ${ INCLUDE_FILES [@] } " ; do
if [ [ " $basename " = = " $special " ] ] ; then
return 0
fi
done
# Check extension
local ext = " ${ file ##*. } "
for include_ext in " ${ INCLUDE_EXTENSIONS [@] } " ; do
if [ [ " $ext " = = " $include_ext " ] ] ; then
return 0
fi
done
return 1
}
# Add header
echo "# Project: jormun-db" >> " $OUTPUT_FILE "
echo " # Generated: $( date) " >> " $OUTPUT_FILE "
echo "" >> " $OUTPUT_FILE "
echo "================================================================================" >> " $OUTPUT_FILE "
echo "" >> " $OUTPUT_FILE "
# Find and concatenate files
while IFS = read -r -d '' file; do
# Get directory path
dir = $( dirname " $file " )
# Skip excluded directories
if should_exclude_dir " $dir " ; then
continue
fi
# Check if file should be included
if should_include_file " $file " ; then
echo " Adding: $file "
# Add file delimiter
echo "================================================================================" >> " $OUTPUT_FILE "
echo " FILE: $file " >> " $OUTPUT_FILE "
echo "================================================================================" >> " $OUTPUT_FILE "
echo "" >> " $OUTPUT_FILE "
# Add file contents
cat " $file " >> " $OUTPUT_FILE "
# Add spacing
echo "" >> " $OUTPUT_FILE "
echo "" >> " $OUTPUT_FILE "
fi
done < <( find . -type f -print0 | sort -z)
echo ""
echo " Done! Output written to: $OUTPUT_FILE "
echo " File size: $( du -h " $OUTPUT_FILE " | cut -f1) "