-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdated_script2readme.txt
More file actions
executable file
·1774 lines (1536 loc) · 71.8 KB
/
updated_script2readme.txt
File metadata and controls
executable file
·1774 lines (1536 loc) · 71.8 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/zsh
#
# script2readme.sh - Generate high-quality README documentation from scripts using Ollama models
# Author: Ian Trimble
# Created: April 28, 2025
# Version: 1.3.0
#
# Enable debug mode only when explicitly requested
if [[ "$1" == "--debug" ]]; then
set -x
shift
fi
# =================== COLORS AND FORMATTING ===================
# Terminal colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
GRAY='\033[0;37m'
BOLD='\033[1m'
DIM='\033[2m'
UNDERLINE='\033[4m'
BLINK='\033[5m'
REVERSE='\033[7m'
RESET='\033[0m'
# Color gradients for progress bar
declare -a GRADIENT
GRADIENT=(
'\033[38;5;27m' '\033[38;5;33m' '\033[38;5;39m' '\033[38;5;45m' '\033[38;5;51m'
'\033[38;5;50m' '\033[38;5;49m' '\033[38;5;48m' '\033[38;5;47m' '\033[38;5;46m'
)
# Check if terminal supports colors
if [ -t 1 ]; then
COLORTERM=1
else
COLORTERM=0
# Reset all color variables to empty strings
RED='' GREEN='' YELLOW='' BLUE='' MAGENTA='' CYAN='' WHITE='' GRAY=''
BOLD='' DIM='' UNDERLINE='' BLINK='' REVERSE='' RESET=''
for i in {0..9}; do GRADIENT[$i]=''; done
fi
# =================== CONFIGURATION ===================
# App information
APP_NAME="Script to README Generator"
APP_VERSION="1.3.0"
APP_AUTHOR="Ian Trimble"
# Directory structure
BENCHMARK_DIR="${HOME}/ollama_benchmarks"
SESSION_ID=$(date +%Y%m%d_%H%M%S)_$(openssl rand -hex 4)
BENCHMARK_LOG="${BENCHMARK_DIR}/benchmark_log.csv"
METRICS_LOG="${BENCHMARK_DIR}/metrics_${SESSION_ID}.json"
CHANGELOG="${BENCHMARK_DIR}/changelog.md"
DETAILED_COMPARISON="${BENCHMARK_DIR}/model_comparisons.md"
README="$(pwd)/README.md"
OLLAMA_API="http://localhost:11434/api/chat"
TEMPLATE_DIR="${HOME}/.script2readme/templates"
CONFIG_FILE="${HOME}/.script2readme/config.json"
# Default model (can be overridden)
DEFAULT_MODEL="qwen2.5-coder:7b"
# Sound effects (if enabled)
SOUND_ENABLED=0
SOUND_COMPLETE="afplay /System/Library/Sounds/Glass.aiff"
SOUND_ERROR="afplay /System/Library/Sounds/Sosumi.aiff"
# Model complexity factors (for time estimation)
declare -A MODEL_COMPLEXITY
MODEL_COMPLEXITY["qwen2.5:1.5b"]=1.0
MODEL_COMPLEXITY["qwen2.5-coder:7b"]=3.5
MODEL_COMPLEXITY["deepseek-coder:6.7b"]=3.0
MODEL_COMPLEXITY["codellama:7b"]=3.0
MODEL_COMPLEXITY["codellama:13b"]=5.5
MODEL_COMPLEXITY["deepseek-coder:latest"]=0.8
MODEL_COMPLEXITY["llama3:8b"]=3.2
MODEL_COMPLEXITY["mistral:7b"]=2.8
MODEL_COMPLEXITY["phi3:mini"]=0.5
# Default for unknown models
MODEL_COMPLEXITY["default"]=2.5
# Model descriptions and strengths
declare -A MODEL_DESCRIPTIONS
MODEL_DESCRIPTIONS["qwen2.5:1.5b"]="Fastest option for simple scripts. Less detailed but great for quick documentation of straightforward code. Uses minimal resources."
MODEL_DESCRIPTIONS["qwen2.5-coder:7b"]="Excellent for code documentation with balanced performance and accuracy. Specializes in understanding programming patterns and explaining them clearly. Good middle ground between speed and quality."
MODEL_DESCRIPTIONS["deepseek-coder:6.7b"]="Specializes in deep code analysis with strong understanding of programming paradigms. Excellent for explaining complex functionality in readable terms."
MODEL_DESCRIPTIONS["codellama:7b"]="Good balance of speed and quality. Strong at API and function documentation. More efficient than 13b while maintaining good quality."
MODEL_DESCRIPTIONS["codellama:13b"]="Most comprehensive documentation but slowest option. Best for complex scripts where detail matters more than speed. Excellent pattern recognition."
MODEL_DESCRIPTIONS["deepseek-coder:latest"]="Optimized for modern coding practices and patterns. Best for documenting complex functions and design patterns. Good balance of speed and thoroughness."
MODEL_DESCRIPTIONS["llama3:8b"]="General-purpose model with decent coding knowledge. Good for scripts with both code and natural language explanations."
MODEL_DESCRIPTIONS["mistral:7b"]="Fast with good reasoning. Handles multi-language scripts well. Excellent for documentation requiring explanations of logic."
MODEL_DESCRIPTIONS["phi3:mini"]="Ultra-fast option for simple scripts. Minimalist documentation but works well for straightforward code."
# Default description for unknown models
MODEL_DESCRIPTIONS["default"]="General-purpose model for code documentation. Performance characteristics unknown."
# Script complexity factors (for time estimation)
LINE_FACTOR=0.3
FUNCTION_FACTOR=2.0
CONDITIONAL_FACTOR=1.5
LOOP_FACTOR=1.2
# Did you know tips
declare -a TIPS
TIPS=(
"You can create custom templates in ${TEMPLATE_DIR}."
"Use the --watch flag to automatically process scripts as they're added to a directory."
"Different models have different strengths - smaller models are faster, larger ones more detailed."
"The --batch flag lets you process multiple scripts at once."
"Your benchmarks are saved to ${BENCHMARK_DIR} for performance analysis."
"You can use --export to generate HTML or PDF documentation from your README."
"The --interactive mode lets you edit the AI-generated content before it's saved."
"Set your preferred default model in ${CONFIG_FILE}."
"Good documentation can reduce project onboarding time by up to 60%."
"Use --update to refresh documentation while preserving your custom edits."
"The qwen2.5-coder:7b model generally produces the most balanced documentation."
"Check model comparison data at ${DETAILED_COMPARISON}."
"For very small scripts, deepseek-coder:latest offers the best speed-to-quality ratio."
"Add a TOC to your README with the --toc flag."
"Run with --stats to see performance metrics for all your previous runs."
)
# Create required directories
mkdir -p "${BENCHMARK_DIR}"
mkdir -p "${TEMPLATE_DIR}"
mkdir -p "$(dirname "${CONFIG_FILE}")"
# Create default config if it doesn't exist
if [ ! -f "${CONFIG_FILE}" ]; then
echo "{\"default_model\": \"${DEFAULT_MODEL}\", \"sound_enabled\": false, \"template\": \"default\", \"preferred_format\": \"enhanced\"}" > "${CONFIG_FILE}"
fi
# Load config if it exists
if [ -f "${CONFIG_FILE}" ]; then
if command -v jq &> /dev/null; then
DEFAULT_MODEL=$(jq -r '.default_model // "qwen2.5-coder:7b"' "${CONFIG_FILE}")
SOUND_ENABLED=$(jq -r '.sound_enabled // false' "${CONFIG_FILE}")
README_FORMAT=$(jq -r '.preferred_format // "enhanced"' "${CONFIG_FILE}")
if [[ "${SOUND_ENABLED}" == "true" ]]; then
SOUND_ENABLED=1
else
SOUND_ENABLED=0
fi
fi
fi
# Initialize benchmark file if it doesn't exist
if [ ! -f "${BENCHMARK_LOG}" ]; then
echo "timestamp,session_id,script_name,script_size_bytes,script_lines,script_chars,model,operation,duration,tokens,cpu_usage,memory_usage,script_complexity,accuracy" > "${BENCHMARK_LOG}"
fi
# Initialize model comparison file if it doesn't exist
if [ ! -f "${DETAILED_COMPARISON}" ]; then
{
echo "# Model Performance Comparison"
echo ""
echo "| Model | Avg Speed | Accuracy | Best For | Notes |"
echo "|-------|-----------|----------|----------|-------|"
echo "| qwen2.5-coder:7b | Medium | High | General documentation | Most balanced results |"
echo "| deepseek-coder:latest | Very Fast | Medium | Quick documentation | Best speed-to-quality ratio |"
echo "| deepseek-coder:6.7b | Medium | High | Detailed analysis | Good technical details |"
echo "| codellama:7b | Medium | Medium | Simple scripts | Occasional inaccuracies |"
echo "| codellama:13b | Slow | Medium-High | Complex scripts | Not worth the extra time |"
} > "${DETAILED_COMPARISON}"
fi
# Initialize changelog if it doesn't exist
if [ ! -f "${CHANGELOG}" ]; then
{
echo "# Script to README Generator Changelog"
echo ""
echo "## Version 1.3.0 - $(date '+%Y-%m-%d')"
echo "- Enhanced README format with better styling"
echo "- Improved model descriptions and selection"
echo "- Fixed time estimation accuracy"
echo "- Added script complexity analysis"
echo "- Added duplicate script versioning"
echo "- Enhanced benchmark metrics and reporting"
echo "- Added model comparison data"
} > "${CHANGELOG}"
else
# Check if version entry exists, add if not
if ! grep -q "## Version ${APP_VERSION}" "${CHANGELOG}"; then
sed -i '' "1a\\
\\
## Version ${APP_VERSION} - $(date '+%Y-%m-%d')\\
- Enhanced README format with better styling\\
- Improved model descriptions and selection\\
- Fixed time estimation accuracy\\
- Added script complexity analysis\\
- Added duplicate script versioning\\
- Enhanced benchmark metrics and reporting\\
- Added model comparison data
" "${CHANGELOG}"
fi
fi
# Initialize metrics JSON log
echo "{\"session_id\": \"${SESSION_ID}\", \"timestamp\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\", \"app_version\": \"${APP_VERSION}\", \"metrics\": []}" > "${METRICS_LOG}"
# =================== HELPER FUNCTIONS ===================
# Function to show the app logo
show_logo() {
clear
echo -e "${BLUE}╔══════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}║ ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}███████╗${GREEN}██████╗${CYAN} ██████╗${YELLOW}███████╗${RED}██████╗ ${MAGENTA}███████╗${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}██╔════╝${GREEN}██╔══██╗${CYAN}██╔════╝${YELLOW}██╔════╝${RED}██╔══██╗${MAGENTA}██╔════╝${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}███████╗${GREEN}██████╔╝${CYAN}██║ ${YELLOW}█████╗ ${RED}██████╔╝${MAGENTA}█████╗ ${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}╚════██║${GREEN}██╔══██╗${CYAN}██║ ${YELLOW}██╔══╝ ${RED}██╔══██╗${MAGENTA}██╔══╝ ${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}███████║${GREEN}██║ ██║${CYAN}╚██████╗${YELLOW}███████╗${RED}██║ ██║${MAGENTA}███████╗${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${MAGENTA}╚══════╝${GREEN}╚═╝ ╚═╝${CYAN} ╚═════╝${YELLOW}╚══════╝${RED}╚═╝ ╚═╝${MAGENTA}╚══════╝${BLUE} ║${RESET}"
echo -e "${BLUE}║ ║${RESET}"
echo -e "${BLUE}║ ${CYAN}Script to README Generator ${WHITE}v${APP_VERSION} ${BLUE} ║${RESET}"
echo -e "${BLUE}║ ${GRAY}By ${APP_AUTHOR} ${BLUE} ║${RESET}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════╝${RESET}"
echo ""
}
# Function to show a random tip
show_tip() {
local tip_index=$((RANDOM % ${#TIPS[@]}))
local tip="${TIPS[$tip_index]}"
echo -e "\n${YELLOW}💡 ${BOLD}Did you know?${RESET} ${tip}${RESET}\n"
}
# Function to log messages with different levels
log_message() {
local level=$1
local message=$2
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
case ${level} in
"INFO")
echo -e "${BLUE}[${timestamp}] ℹ️ ${RESET}${message}"
;;
"SUCCESS")
echo -e "${GREEN}[${timestamp}] ✅ ${BOLD}${message}${RESET}"
;;
"WARNING")
echo -e "${YELLOW}[${timestamp}] ⚠️ ${BOLD}${message}${RESET}"
;;
"ERROR")
echo -e "${RED}[${timestamp}] ❌ ${BOLD}${message}${RESET}"
;;
"DEBUG")
if [[ "$1" == "--debug" ]]; then
echo -e "${GRAY}[${timestamp}] 🔍 ${message}${RESET}"
fi
;;
*)
echo -e "[${timestamp}] ${message}"
;;
esac
}
# Function to play sounds if enabled
play_sound() {
local sound_type=$1
if [ ${SOUND_ENABLED} -eq 1 ]; then
case ${sound_type} in
"complete")
eval ${SOUND_COMPLETE} &> /dev/null &
;;
"error")
eval ${SOUND_ERROR} &> /dev/null &
;;
esac
fi
}
# Function to display an animated spinner
spinner() {
local pid=$1
local delay=0.1
local spinstr='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
while kill -0 $pid 2>/dev/null; do
local temp=${spinstr#?}
printf " %c " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b"
done
printf " \b\b\b\b"
}
# Function to display progress
display_progress() {
local progress=$1
local duration=$2
local width=40
local filled=$((width * progress / 100))
local empty=$((width - filled))
local bar=""
# Create gradient filled part
for ((i = 0; i < filled; i++)); do
local color_index=$((i * 10 / width))
bar="${bar}${GRADIENT[$color_index]}█"
done
# Create empty part
for ((i = 0; i < empty; i++)); do
bar="${bar}${GRAY}░"
done
# Print the bar
printf "\r${WHITE}[${RESET}${bar}${RESET}${WHITE}]${RESET} ${BOLD}%3d%%${RESET} ${WHITE}(${CYAN}%s${WHITE})${RESET}" $progress "$duration"
}
# Function to format time in human-readable format
format_time() {
local seconds=$1
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
if [ $minutes -gt 0 ]; then
echo "${minutes}m ${remaining_seconds}s"
else
echo "${seconds}s"
fi
}
# Function to calculate script complexity score
calculate_complexity() {
local content="$1"
local line_count="$2"
# Count script features
local function_count=$(echo "${content}" | grep -c "function " || echo "0")
local if_count=$(echo "${content}" | grep -c "if " || echo "0")
local case_count=$(echo "${content}" | grep -c "case " || echo "0")
local for_count=$(echo "${content}" | grep -c "for " || echo "0")
local while_count=$(echo "${content}" | grep -c "while " || echo "0")
# Calculate complexity score based on features
local complexity=$(echo "scale=2; ${line_count} * ${LINE_FACTOR} +
${function_count} * ${FUNCTION_FACTOR} +
(${if_count} + ${case_count}) * ${CONDITIONAL_FACTOR} +
(${for_count} + ${while_count}) * ${LOOP_FACTOR}" | bc)
# Ensure minimum complexity of 1.0
if (( $(echo "$complexity < 1.0" | bc -l) )); then
complexity=1.0
fi
# Return the complexity score
echo $complexity
}
# Function to estimate completion time
estimate_completion_time() {
local script_size=$1
local script_complexity=$2
local model=$3
# Get model complexity factor
local model_factor=${MODEL_COMPLEXITY[$model]}
if [ -z "$model_factor" ]; then
model_factor=${MODEL_COMPLEXITY["default"]}
fi
# Base time in seconds per KB with adjustment for complexity
local base_time=2
# Adjust based on script size (larger scripts may take disproportionately longer)
local size_factor=$(printf "%.2f" $(echo "scale=2; ($script_size / 1024) ^ 0.6" | bc))
# Calculate estimated seconds with complexity factored in
local complexity_adjustment=$(printf "%.2f" $(echo "scale=2; $script_complexity * 0.8" | bc))
local estimate=$(printf "%.0f" $(echo "scale=0; $base_time * $size_factor * $model_factor * $complexity_adjustment" | bc))
# Ensure minimum reasonable time
if [ $estimate -lt 10 ]; then
estimate=10
fi
echo $estimate
}
# Function to display model description
show_model_description() {
local model=$1
local description=""
# Get description
if [ -n "${MODEL_DESCRIPTIONS[$model]}" ]; then
description="${MODEL_DESCRIPTIONS[$model]}"
else
description="${MODEL_DESCRIPTIONS["default"]}"
fi
# Get complexity factor
local complexity=${MODEL_COMPLEXITY[$model]}
if [ -z "$complexity" ]; then
complexity=${MODEL_COMPLEXITY["default"]}
fi
# Calculate speed category
local speed=""
local speed_color=""
if (( $(echo "$complexity < 1.5" | bc -l) )); then
speed="Very Fast"
speed_color="${GREEN}"
elif (( $(echo "$complexity < 2.5" | bc -l) )); then
speed="Fast"
speed_color="${CYAN}"
elif (( $(echo "$complexity < 4.0" | bc -l) )); then
speed="Medium"
speed_color="${YELLOW}"
else
speed="Slow"
speed_color="${RED}"
fi
echo -e "${MAGENTA}${BOLD}${model}${RESET}"
echo -e "${GRAY}${description}${RESET}"
echo -e "${GRAY}• Speed: ${speed_color}${speed}${RESET}"
echo -e "${GRAY}• Performance factor: ${WHITE}${complexity}x${RESET}"
# If we have benchmark data, display it
if [ -f "${BENCHMARK_LOG}" ]; then
local avg_time=$(grep "${model}" "${BENCHMARK_LOG}" | grep "total_analysis" | awk -F',' '{sum+=$9; count++} END {if(count>0) print sum/count; else print "N/A"}')
local runs=$(grep "${model}" "${BENCHMARK_LOG}" | grep "total_analysis" | wc -l | tr -d ' ')
if [[ "$avg_time" != "N/A" && $runs -gt 0 ]]; then
echo -e "${GRAY}• Average run time: ${WHITE}$(printf "%.2f" ${avg_time})s${RESET} (${runs} previous runs)"
fi
fi
echo ""
}
# Function to display usage information
show_usage() {
echo -e "${CYAN}${BOLD}${APP_NAME}${RESET} ${WHITE}(v${APP_VERSION})${RESET}"
echo -e "${GRAY}Generates README documentation from script files using Ollama models${RESET}"
echo ""
echo -e "${YELLOW}${BOLD}Usage:${RESET} $0 ${GREEN}[OPTIONS]${RESET} ${MAGENTA}<input_file>${RESET} ${BLUE}[model]${RESET}"
echo ""
echo -e "${YELLOW}${BOLD}Options:${RESET}"
echo -e " ${GREEN}--debug${RESET} Enable debug mode"
echo -e " ${GREEN}--help${RESET} Show this help message"
echo -e " ${GREEN}--list-models${RESET} List available Ollama models"
echo -e " ${GREEN}--version${RESET} Show version information"
echo -e " ${GREEN}--no-estimate${RESET} Skip time estimation"
echo -e " ${GREEN}--no-color${RESET} Disable colored output"
echo -e " ${GREEN}--sound${RESET} Enable sound notifications"
echo -e " ${GREEN}--batch${RESET} ${BLUE}<pattern>${RESET} Process multiple files matching pattern"
echo -e " ${GREEN}--watch${RESET} ${BLUE}<directory>${RESET} Watch directory for new scripts and process them"
echo -e " ${GREEN}--template${RESET} ${BLUE}<name>${RESET} Use specified template (default: standard)"
echo -e " ${GREEN}--interactive${RESET} Edit AI-generated documentation before saving"
echo -e " ${GREEN}--update${RESET} Update existing documentation preserving manual edits"
echo -e " ${GREEN}--export${RESET} ${BLUE}<format>${RESET} Export documentation to specified format (html, pdf)"
echo -e " ${GREEN}--format${RESET} ${BLUE}<style>${RESET} README format style (basic, enhanced, fancy)"
echo -e " ${GREEN}--toc${RESET} Add table of contents to README"
echo -e " ${GREEN}--config${RESET} Create or update configuration"
echo -e " ${GREEN}--stats${RESET} Show benchmark statistics for all runs"
echo -e " ${GREEN}--compare${RESET} Compare multiple models on the same script"
echo ""
echo -e "${YELLOW}${BOLD}Arguments:${RESET}"
echo -e " ${MAGENTA}<input_file>${RESET} Path to script file to document"
echo -e " ${BLUE}[model]${RESET} Optional Ollama model name (default: ${WHITE}${DEFAULT_MODEL}${RESET})"
echo ""
echo -e "${YELLOW}${BOLD}Examples:${RESET}"
echo -e " ${GRAY}$0 my_script.sh${RESET}"
echo -e " ${GRAY}$0 my_script.sh codellama:7b${RESET}"
echo -e " ${GRAY}$0 --batch \"*.sh\" --template code${RESET}"
echo -e " ${GRAY}$0 --watch ~/scripts --template minimal${RESET}"
echo -e " ${GRAY}$0 my_script.sh --format fancy --toc${RESET}"
echo -e " ${GRAY}$0 --compare my_script.sh${RESET}"
echo ""
echo -e "${YELLOW}${BOLD}Output:${RESET}"
echo -e " - Updates README.md in the current directory with script documentation"
echo -e " - Logs performance metrics and benchmarks to ${BENCHMARK_DIR}"
echo ""
show_tip
exit 0
}
# Function to display version information
show_version() {
echo -e "${CYAN}${BOLD}${APP_NAME}${RESET} ${WHITE}v${APP_VERSION}${RESET}"
echo -e "${GRAY}Author: ${WHITE}${APP_AUTHOR}${RESET}"
echo -e "${GRAY}Created: April 28, 2025${RESET}"
echo -e "${GRAY}License: MIT${RESET}"
exit 0
}
# Function to display benchmark statistics
show_benchmark_stats() {
if [ ! -f "${BENCHMARK_LOG}" ]; then
log_message "ERROR" "No benchmark data found."
exit 1
fi
echo -e "${CYAN}${BOLD}Benchmark Statistics${RESET}"
echo ""
# Get model statistics
echo -e "${YELLOW}${BOLD}Model Performance${RESET}"
echo -e "${WHITE}|--------------------|-----------|------------|----------|${RESET}"
echo -e "${WHITE}| Model | Avg Time | Success % | Runs |${RESET}"
echo -e "${WHITE}|--------------------|-----------|------------|----------|${RESET}"
# Extract unique models
local models=$(tail -n +2 "${BENCHMARK_LOG}" | awk -F',' '{print $7}' | sort | uniq)
for model in $models; do
# Skip system entries
if [[ "$model" == "system" ]]; then
continue
fi
local runs=$(grep "${model}" "${BENCHMARK_LOG}" | grep "total_analysis" | wc -l | tr -d ' ')
local avg_time=$(grep "${model}" "${BENCHMARK_LOG}" | grep "total_analysis" | awk -F',' '{sum+=$9; count++} END {if(count>0) print sum/count; else print "N/A"}')
# Calculate accuracy if available
local accuracy="N/A"
local accuracy_data=$(grep "${model}" "${BENCHMARK_LOG}" | grep "total_analysis" | awk -F',' '{if($12!="") print $12}')
if [ -n "$accuracy_data" ]; then
accuracy=$(echo "$accuracy_data" | awk '{sum+=$1; count++} END {if(count>0) print (sum/count)*100; else print "N/A"}')
if [[ "$accuracy" != "N/A" ]]; then
accuracy="$(printf "%.1f" ${accuracy})%"
fi
fi
# Format the model name and values for display
local model_display=$(printf "%-18s" "${model}")
local time_display="N/A"
if [[ "$avg_time" != "N/A" ]]; then
time_display="$(printf "%.2f" ${avg_time})s"
fi
local time_display=$(printf "%-9s" "${time_display}")
local accuracy_display=$(printf "%-10s" "${accuracy}")
local runs_display=$(printf "%-8s" "${runs}")
echo -e "| ${MAGENTA}${model_display}${RESET} | ${CYAN}${time_display}${RESET} | ${GREEN}${accuracy_display}${RESET} | ${YELLOW}${runs_display}${RESET} |"
done
echo -e "${WHITE}|--------------------|-----------|------------|----------|${RESET}"
echo ""
# Script type statistics
echo -e "${YELLOW}${BOLD}Script Types${RESET}"
echo -e "${WHITE}|------------|---------|------------|${RESET}"
echo -e "${WHITE}| Type | Count | Avg Time |${RESET}"
echo -e "${WHITE}|------------|---------|------------|${RESET}"
# Extract script extensions and count them
local exts=$(for file in $(tail -n +2 "${BENCHMARK_LOG}" | awk -F',' '{print $3}' | grep -v "system"); do
echo "${file##*.}";
done | sort | uniq)
for ext in $exts; do
if [[ -z "$ext" || "$ext" == "system" ]]; then
continue
fi
local count=$(grep "\.${ext}" "${BENCHMARK_LOG}" | grep "total_analysis" | wc -l | tr -d ' ')
local avg_time=$(grep "\.${ext}" "${BENCHMARK_LOG}" | grep "total_analysis" | awk -F',' '{sum+=$9; count++} END {if(count>0) print sum/count; else print "N/A"}')
# Format for display
local ext_display=$(printf "%-10s" "${ext}")
local count_display=$(printf "%-7s" "${count}")
local time_display="N/A"
if [[ "$avg_time" != "N/A" ]]; then
time_display="$(printf "%.2f" ${avg_time})s"
fi
local time_display=$(printf "%-10s" "${time_display}")
echo -e "| ${CYAN}${ext_display}${RESET} | ${YELLOW}${count_display}${RESET} | ${GREEN}${time_display}${RESET} |"
done
echo -e "${WHITE}|------------|---------|------------|${RESET}"
echo ""
# Overall statistics
local total_runs=$(grep "total_analysis" "${BENCHMARK_LOG}" | wc -l | tr -d ' ')
local avg_total_time=$(grep "total_analysis" "${BENCHMARK_LOG}" | awk -F',' '{sum+=$9; count++} END {if(count>0) print sum/count; else print "N/A"}')
local avg_script_size=$(grep "total_analysis" "${BENCHMARK_LOG}" | awk -F',' '{sum+=$4; count++} END {if(count>0) print sum/count; else print "N/A"}')
local avg_script_lines=$(grep "total_analysis" "${BENCHMARK_LOG}" | awk -F',' '{sum+=$5; count++} END {if(count>0) print sum/count; else print "N/A"}')
# Format times
local avg_time_display="N/A"
if [[ "$avg_total_time" != "N/A" ]]; then
avg_time_display="$(printf "%.2f" ${avg_total_time})s"
fi
echo -e "${YELLOW}${BOLD}Overall Statistics${RESET}"
echo -e "${GRAY}Total runs: ${WHITE}${total_runs}${RESET}"
echo -e "${GRAY}Average runtime: ${WHITE}${avg_time_display}${RESET}"
if [[ "$avg_script_size" != "N/A" ]]; then
echo -e "${GRAY}Average script size: ${WHITE}$(printf "%.2f" ${avg_script_size}) bytes${RESET}"
fi
if [[ "$avg_script_lines" != "N/A" ]]; then
echo -e "${GRAY}Average script lines: ${WHITE}$(printf "%.1f" ${avg_script_lines}) lines${RESET}"
fi
echo ""
# Location of benchmark files
echo -e "${YELLOW}${BOLD}Benchmark Files${RESET}"
echo -e "${GRAY}CSV log: ${WHITE}${BENCHMARK_LOG}${RESET}"
echo -e "${GRAY}Model comparison: ${WHITE}${DETAILED_COMPARISON}${RESET}"
echo -e "${GRAY}Session logs: ${WHITE}${BENCHMARK_DIR}/metrics_*.json${RESET}"
echo -e "${GRAY}Responses: ${WHITE}${BENCHMARK_DIR}/response_*.md${RESET}"
echo ""
exit 0
}
# Function to compare model outputs
compare_models() {
local input_file=$1
log_message "INFO" "Comparing models for ${input_file}..."
# Validate the input file
if [ ! -f "${input_file}" ]; then
log_message "ERROR" "Input file '${input_file}' does not exist."
exit 1
fi
# Get available models
get_models
# Ask which models to compare if in interactive mode
local models_to_compare=()
if is_terminal; then
echo -e "${YELLOW}${BOLD}Select models to compare (space-separated numbers, e.g. '1 3 5'):${RESET}"
# Display models with numbers
for ((i=1; i<=${#models[@]}; i++)); do
local model="${models[$i]}"
echo -e "${WHITE}${i})${RESET} ${MAGENTA}${model}${RESET}"
done
# Read user selection
read -p "Models to compare: " model_selection
# Convert selection to models
for num in $model_selection; do
if [[ "$num" =~ ^[0-9]+$ ]] && [ "$num" -ge 1 ] && [ "$num" -le ${#models[@]} ]; then
models_to_compare+=("${models[$num]}")
fi
done
else
# Non-interactive: use predefined good models
models_to_compare=("qwen2.5-coder:7b" "deepseek-coder:latest" "codellama:7b")
fi
# If no models selected, use default
if [ ${#models_to_compare[@]} -eq 0 ]; then
log_message "WARNING" "No models selected. Using default comparison set."
models_to_compare=("qwen2.5-coder:7b" "deepseek-coder:latest" "codellama:7b")
fi
# Create a comparison directory
local comparison_dir="${BENCHMARK_DIR}/comparison_${SESSION_ID}"
mkdir -p "${comparison_dir}"
# Create comparison markdown file
local comparison_file="${comparison_dir}/model_comparison.md"
# Initialize comparison file
{
echo "# Model Comparison for $(basename "${input_file}")"
echo ""
echo "Generated on $(date '+%Y-%m-%d %H:%M:%S')"
echo ""
echo "## Script Information"
echo ""
echo "| Property | Value |"
echo "|----------|-------|"
echo "| Filename | $(basename "${input_file}") |"
echo "| Size | $(stat -f%z "${input_file}") bytes |"
echo "| Lines | $(wc -l < "${input_file}" | tr -d ' ') |"
echo ""
echo "## Performance Comparison"
echo ""
echo "| Model | Time | Word Count | Accuracy | Notes |"
echo "|-------|------|------------|----------|-------|"
} > "${comparison_file}"
# Validate and process with each model
for model in "${models_to_compare[@]}"; do
log_message "INFO" "Testing with model: ${model}"
# Skip if model doesn't exist
if ! ollama list | grep -q "${model}"; then
log_message "WARNING" "Model '${model}' not found. Skipping."
continue
fi
# Run with current model
local model_start_time=$(date +%s.%N)
# Validate input file
CONTENT=$(cat "${input_file}")
FILE_SIZE=$(stat -f%z "${input_file}")
LINE_COUNT=$(echo "${CONTENT}" | wc -l | tr -d ' ')
CHAR_COUNT=$(echo "${CONTENT}" | wc -c | tr -d ' ')
SCRIPT_TYPE="${input_file##*.}"
# Calculate script complexity
SCRIPT_COMPLEXITY=$(calculate_complexity "${CONTENT}" "${LINE_COUNT}")
# Create request payload
local payload=$(jq -n \
--arg model "${model}" \
--arg content "${CONTENT}" \
--arg filename "$(basename "${input_file}")" \
--arg script_type "${SCRIPT_TYPE}" \
'{
"model": $model,
"messages": [
{
"role": "system",
"content": "You are an expert code documentarian tasked with producing professional, accurate, and comprehensive documentation. Analyze the provided script with precision, describing only the functionality explicitly present in the code. Generate a detailed Markdown README section that is clear, thorough, and professionally structured, suitable for developers and end-users."
},
{
"role": "user",
"content": "Analyze the following script provided as plain text. Pay close attention to specific elements such as references to applications, system paths, and command-line tools. Consider the script'\''s potential impact on the system.\n\nGenerate a Markdown README section with these sections:\n\n- **Overview**: Summarize the script'\''s purpose and primary actions.\n- **Requirements**: List prerequisites inferred from the script.\n- **Usage**: Provide precise instructions for running the script.\n- **What the Script Does**: Describe the script'\''s operations step-by-step.\n- **Important Notes**: Highlight critical details derived from the script.\n- **Disclaimer**: Warn about risks of running the script.\n\nFile: \($filename)\n\nScript Content:\n\($content)"
}
],
"stream": false
}')
# Temporary file for response
local temp_response=$(mktemp)
# Send the request
log_message "INFO" "Sending request to Ollama API for ${model}..."
curl -s -X POST "${OLLAMA_API}" \
-H "Content-Type: application/json" \
-d "${payload}" > "${temp_response}"
# Check for errors
if grep -q "error" "${temp_response}"; then
log_message "ERROR" "Error in Ollama response for ${model}:"
cat "${temp_response}"
continue
fi
# Extract response content
local RESPONSE=""
if jq -e '.message.content' "${temp_response}" > /dev/null 2>&1; then
RESPONSE=$(jq -r '.message.content' "${temp_response}")
else
# Fallback methods
RESPONSE=$(grep -o '"content":"[^"]*"' "${temp_response}" | sed 's/"content":"//;s/"//')
if [ -z "${RESPONSE}" ]; then
RESPONSE=$(perl -0777 -ne 'print $1 if /"content":"(.*?)"/s' "${temp_response}")
fi
if [ -z "${RESPONSE}" ]; then
RESPONSE=$(cat "${temp_response}" | python3 -c "
import json, sys
try:
data = json.load(sys.stdin)
print(data['message']['content'])
except Exception as e:
print(f'Error parsing JSON: {e}', file=sys.stderr)
sys.exit(1)
" 2>/dev/null)
fi
fi
# Save model response
local model_response_file="${comparison_dir}/${model//[:\/]/_}.md"
echo "${RESPONSE}" > "${model_response_file}"
# Calculate timing
local model_end_time=$(date +%s.%N)
local model_duration=$(printf "%.2f" $(echo "${model_end_time} - ${model_start_time}" | bc))
# Calculate statistics
local word_count=$(echo "${RESPONSE}" | wc -w | tr -d ' ')
# Add to comparison file
echo "| ${model} | ${model_duration}s | ${word_count} | - | [View]($(basename "${model_response_file}")) |" >> "${comparison_file}"
done
# Complete comparison file
{
echo ""
echo "## Summary"
echo ""
echo "This comparison shows how different models analyze the same script. The quality of documentation can vary significantly between models, with some providing more detailed explanations while others may be more concise or faster."
echo ""
echo "Generally, qwen2.5-coder:7b provides the most balanced results, deepseek-coder:latest is fastest, and codellama:13b is most comprehensive but slowest."
echo ""
echo "## How to View Full Outputs"
echo ""
echo "The individual model outputs are saved in the same directory as this file:"
echo ""
echo "```"
echo "${comparison_dir}"
echo "```"
} >> "${comparison_file}"
# Output results
log_message "SUCCESS" "Comparison complete!"
log_message "INFO" "Results saved to: ${comparison_file}"
# Open the comparison file if on macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
open "${comparison_file}"
fi
exit 0
}
# Function to update config
update_config() {
echo -e "${CYAN}${BOLD}Configuration Setup${RESET}"
echo ""
# Ask for default model
echo -e "${YELLOW}Default model:${RESET} (current: ${WHITE}${DEFAULT_MODEL}${RESET})"
read -r new_model
if [ -z "$new_model" ]; then
new_model="${DEFAULT_MODEL}"
fi
# Ask for sound preference
echo -e "${YELLOW}Enable sound effects?${RESET} (y/N)"
read -r sound_pref
if [[ "${sound_pref}" =~ ^[Yy]$ ]]; then
sound_enabled="true"
else
sound_enabled="false"
fi
# Ask for preferred README format
echo -e "${YELLOW}Preferred README format:${RESET} (basic, enhanced, fancy) [current: ${README_FORMAT}]"
read -r format_pref
if [ -z "$format_pref" ]; then
format_pref="${README_FORMAT}"
fi
if [[ ! "${format_pref}" =~ ^(basic|enhanced|fancy)$ ]]; then
format_pref="enhanced"
fi
# Write to config file
echo "{\"default_model\": \"${new_model}\", \"sound_enabled\": ${sound_enabled}, \"template\": \"default\", \"preferred_format\": \"${format_pref}\"}" > "${CONFIG_FILE}"
echo -e "${GREEN}${BOLD}Configuration updated!${RESET}"
exit 0
}
# Function to get system information
get_system_info() {
local cpu_info=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo "Unknown")
local memory_info=$(sysctl -n hw.memsize 2>/dev/null | awk '{print int($1/1024/1024/1024) " GB"}' || echo "Unknown")
local os_info=$(sw_vers -productVersion 2>/dev/null || echo "Unknown")
local ollama_version=$(ollama version 2>/dev/null || echo "Unknown")
# Add system info to metrics log
jq --arg cpu "${cpu_info}" \
--arg mem "${memory_info}" \
--arg os "${os_info}" \
--arg ollama "${ollama_version}" \
'.system_info = {"cpu": $cpu, "memory": $mem, "os": $os, "ollama_version": $ollama}' "${METRICS_LOG}" > "${METRICS_LOG}.tmp" && mv "${METRICS_LOG}.tmp" "${METRICS_LOG}"
log_message "INFO" "System Info: CPU: ${cpu_info}, Memory: ${memory_info}, OS: ${os_info}, Ollama: ${ollama_version}"
}
# Function to get current resource usage
get_resource_usage() {
local cpu_usage=$(ps -o %cpu= -p $$ | awk '{print $1}')
local memory_usage=$(ps -o rss= -p $$ | awk '{print int($1/1024) " MB"}')
echo "${cpu_usage},${memory_usage}"
}
# Function to log benchmark data
log_benchmark() {
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local script_name=$1
local script_size=$2
local script_lines=$3
local script_chars=$4
local model=$5
local operation=$6
local duration=$7
local token_count=$8
local complexity=$9
local accuracy=${10}
# Get resource usage
local resource_usage=$(get_resource_usage)
local cpu_usage=$(echo ${resource_usage} | cut -d, -f1)
local memory_usage=$(echo ${resource_usage} | cut -d, -f2)
# Log to CSV for detailed data
echo "${timestamp},${SESSION_ID},${script_name},${script_size},${script_lines},${script_chars},${model},${operation},${duration},${token_count},${cpu_usage},${memory_usage},${complexity},${accuracy}" >> "${BENCHMARK_LOG}"
# Add metric to JSON log
jq --arg timestamp "${timestamp}" \
--arg script "${script_name}" \
--arg size "${script_size}" \
--arg lines "${script_lines}" \
--arg chars "${script_chars}" \
--arg model "${model}" \
--arg op "${operation}" \
--arg dur "${duration}" \
--arg tokens "${token_count}" \
--arg cpu "${cpu_usage}" \
--arg mem "${memory_usage}" \
--arg complexity "${complexity}" \
--arg accuracy "${accuracy}" \
'.metrics += [{"timestamp": $timestamp, "script": $script, "size_bytes": $size, "line_count": $lines, "char_count": $chars, "model": $model, "operation": $op, "duration": $dur, "token_count": $tokens, "cpu_usage": $cpu, "memory_usage": $mem, "complexity": $complexity, "accuracy": $accuracy}]' "${METRICS_LOG}" > "${METRICS_LOG}.tmp" && mv "${METRICS_LOG}.tmp" "${METRICS_LOG}"
# Return for chaining
echo "${operation}:${duration}"
}
# Function to generate a benchmark summary
generate_benchmark_summary() {
local model=$1
local script_name=$2
local total_time=$3
local api_time=$4
local parse_time=$5
local script_size=$6
local script_lines=$7
local script_chars=$8
local token_count=$9
local estimated_time=${10}
local complexity=${11}
echo -e "${BLUE}╔══════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}║ ${CYAN}${BOLD}README GENERATION COMPLETE ${RESET}${BLUE}║${RESET}"
echo -e "${BLUE}╠══════════════════════════════════════════════════════╣${RESET}"
echo -e "${BLUE}║ ${WHITE}📄 Script:${RESET} ${YELLOW}${script_name}${RESET}$(printf "%$((40-${#script_name}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}🤖 Model:${RESET} ${MAGENTA}${model}${RESET}$(printf "%$((41-${#model}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}⏱️ Total time:${RESET} ${GREEN}${total_time}s${RESET}$(printf "%$((37-${#total_time}))s" "")${BLUE}║${RESET}"
if [ -n "$estimated_time" ]; then
local accuracy=0
if [ "$total_time" -gt 0 ]; then
accuracy=$(printf "%.1f" $(echo "scale=1; (${estimated_time} / ${total_time}) * 100" | bc 2>/dev/null || echo "0"))
if [ -z "$accuracy" ] || [ "$accuracy" = "0" ]; then
accuracy="N/A"
fi
else
accuracy="N/A"
fi
echo -e "${BLUE}║ ${WHITE}🔮 Est. vs Actual:${RESET} ${estimated_time}s vs ${total_time}s (${accuracy}%)$(printf "%$((21-${#estimated_time}-${#total_time}-${#accuracy}))s" "")${BLUE}║${RESET}"
fi
echo -e "${BLUE}║ ${WHITE}🔄 API request time:${RESET} ${CYAN}${api_time}s${RESET}$(printf "%$((31-${#api_time}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}🔍 Response parse time:${RESET} ${CYAN}${parse_time}s${RESET}$(printf "%$((29-${#parse_time}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}📝 Response size:${RESET} ~${token_count} words$(printf "%$((33-${#token_count}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}🧮 Script complexity:${RESET} ${complexity}$(printf "%$((31-${#complexity}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}📂 Script metrics:${RESET}$(printf "%$((35))s" "")${BLUE}║${RESET}"
local kb_size=$(printf "%.2f" $(echo "scale=2; ${script_size}/1024" | bc))
echo -e "${BLUE}║ ${GRAY}- Size: ${script_size} bytes (${kb_size} KB)${RESET}$(printf "%$((38-${#script_size}-${#kb_size}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${GRAY}- Lines: ${script_lines}${RESET}$(printf "%$((43-${#script_lines}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${GRAY}- Characters: ${script_chars}${RESET}$(printf "%$((37-${#script_chars}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}╠══════════════════════════════════════════════════════╣${RESET}"
echo -e "${BLUE}║ ${GRAY}📋 Session ID: ${DIM}${SESSION_ID}${RESET}$(printf "%$((38-${#SESSION_ID}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════╝${RESET}"
}
# Function to show benchmark location
show_benchmark_location() {
echo -e "${BLUE}╔══════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}║ ${CYAN}${BOLD}BENCHMARK FILES LOCATION ${RESET}${BLUE}║${RESET}"
echo -e "${BLUE}╠══════════════════════════════════════════════════════╣${RESET}"
echo -e "${BLUE}║ ${WHITE}Metrics Log:${RESET} ${YELLOW}${METRICS_LOG}${RESET}$(printf "%$((40-${#METRICS_LOG}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}CSV History:${RESET} ${YELLOW}${BENCHMARK_LOG}${RESET}$(printf "%$((40-${#BENCHMARK_LOG}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}Response:${RESET} ${YELLOW}${BENCHMARK_DIR}/response_${SESSION_ID}.md${RESET}$(printf "%$((40-${#BENCHMARK_DIR}-${#SESSION_ID}-15))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}║ ${WHITE}Changelog:${RESET} ${YELLOW}${CHANGELOG}${RESET}$(printf "%$((40-${#CHANGELOG}))s" "")${BLUE}║${RESET}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════╝${RESET}"
}
# Function to update the changelog
update_changelog() {
local script_name=$1
local model=$2
local duration=$3
# Get the current date
local today=$(date '+%Y-%m-%d')