91 lines
2.2 KiB
Bash
Executable File
91 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Output file
|
|
OUTPUT_FILE="project_context.txt"
|
|
|
|
# Directories to exclude
|
|
EXCLUDE_DIRS=("zig-out" "data" ".git" "node_modules" ".zig-cache")
|
|
|
|
# File extensions to include (add more as needed)
|
|
INCLUDE_EXTENSIONS=("zig" "md" "yml" "yaml" "Makefile" "Dockerfile")
|
|
|
|
# Special files to include (without extension)
|
|
INCLUDE_FILES=("build.zig" "build.zig.zon" "Makefile" "Dockerfile" "docker-compose.yml" "README.md")
|
|
|
|
# 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: zyna-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)"
|