forked from toema/n8n-playwright
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI
More file actions
executable file
·56 lines (46 loc) · 1.69 KB
/
AI
File metadata and controls
executable file
·56 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
## This script turns all you src code into .txt so you feed this codebase into any selected LLM with a small context
# Create ai_files directory if it doesn't exist
mkdir -p ai_files
# Remove any existing files in ai_files
rm -rf ai_files/*
# Associative array to keep track of file counts
declare -A file_counts
# Function to copy file with path comment and handle naming conflicts
copy_file() {
local file=$1
local relative_path=${file#./}
local base_name=$(basename "${file%.*}")
if [[ -v "file_counts[$base_name]" ]]; then
file_counts[$base_name]=$((file_counts[$base_name] + 1))
dest_file="ai_files/${base_name}_${file_counts[$base_name]}.txt"
else
# file_counts[$base_name]=22
dest_file="ai_files/${base_name}.txt"
fi
echo "// File: $relative_path" > "$dest_file"
cat "$file" >> "$dest_file"
}
# Copy all files from the base directory to ai_files, excluding dot files and directories
find . -type f \
-not -path '*/\.*' \
-not -name '.*' \
-not -path './ai_files/*' \
-not -path './pnpm-lock.yaml' \
-not -path './*.txt' \
-not -path './*.md' \
-not -path './*.svg' \
-not -path './package-lock.json' \
-not -path './nodes/browsers/*' \
-not -path './dist/nodes/browsers/*' \
-not -path './AI' \
-not -path './node_modules/*' \
| while read -r file; do
copy_file "$file"
done
# Add ai_files to git
# git add ai_files
# Inform the user
echo "Files copied from the base directory to ai_files, paths added as comments, and extensions changed to .txt"
echo "Files and folders starting with dots were excluded"
echo "Files with the same name have been numbered to avoid conflicts"