|
|
|
@ -1,116 +1,72 @@ |
|
|
|
#!/bin/bash |
|
|
|
#!/bin/bash |
|
|
|
# Generate interface summaries for all modules in src/ |
|
|
|
# Generate interface summaries for all modules in src/ |
|
|
|
# Outputs to tmp/summaries/ (per-module cache) and supports combining into one file |
|
|
|
# Creates temporary markdown files alongside source files for quick reference |
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
set -e |
|
|
|
|
|
|
|
|
|
|
|
SRC_DIR="/home/agent/dev/claudes_game/src" |
|
|
|
SRC_DIR="/home/agent/dev/claudes_game/src" |
|
|
|
TEMP_EXT=".summary.md" |
|
|
|
TEMP_EXT=".summary.md" |
|
|
|
SUMMARY_DIR="tmp/" |
|
|
|
|
|
|
|
PROMPT_FILE="scripts/prompt.md" |
|
|
|
PROMPT_FILE="scripts/prompt.md" |
|
|
|
LLM_PROVIDER="llama.cpp" |
|
|
|
|
|
|
|
LLM_MODEL="Qwen3.6-35B" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Discover modules from src/ directory |
|
|
|
# Function to generate prompt for a specific module |
|
|
|
MODULES=() |
|
|
|
|
|
|
|
for h in src/*.h; do |
|
|
|
|
|
|
|
mod=$(basename "$h" .h) |
|
|
|
|
|
|
|
MODULES+=("$mod") |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Generate prompt for a specific module |
|
|
|
|
|
|
|
generate_prompt() { |
|
|
|
generate_prompt() { |
|
|
|
local module_name="$1" |
|
|
|
local module_name="$1" |
|
|
|
sed "s|\${module_name}|$module_name|g" "$PROMPT_FILE" \ |
|
|
|
sed "s|\${module_name}|$module_name|g" "$PROMPT_FILE" | sed "s|\${SRC_DIR}|$SRC_DIR|g" |
|
|
|
| sed "s|\${SRC_DIR}|$SRC_DIR|g" \ |
|
|
|
|
|
|
|
| sed "s|\${SUMMARY_DIR}|$SUMMARY_DIR|g" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Check if summary needs regeneration based on file timestamps |
|
|
|
# Function to process a single module |
|
|
|
needs_update() { |
|
|
|
|
|
|
|
local source_file="$1" |
|
|
|
|
|
|
|
local summary_file="$2" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Regenerate if summary doesn't exist |
|
|
|
|
|
|
|
[ ! -f "$summary_file" ] && return 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Regenerate if .h file is newer |
|
|
|
|
|
|
|
[ "$source_file" -nt "$summary_file" ] && return 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Regenerate if .cpp file is newer (if it exists) |
|
|
|
|
|
|
|
local cpp_file="${SRC_DIR}/$(basename "$source_file" .h).cpp" |
|
|
|
|
|
|
|
if [ -f "$cpp_file" ] && [ "$cpp_file" -nt "$summary_file" ]; then |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Process a single module header/cpp pair |
|
|
|
|
|
|
|
process_module() { |
|
|
|
process_module() { |
|
|
|
local module_name="$1" |
|
|
|
local module_name="$1" |
|
|
|
local header_file="${SRC_DIR}/${module_name}.h" |
|
|
|
local header_file="${SRC_DIR}/${module_name}.h" |
|
|
|
local output_file="${SUMMARY_DIR}/${module_name}${TEMP_EXT}" |
|
|
|
local output_file="${SRC_DIR}/${module_name}${TEMP_EXT}" |
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$header_file" ]; then |
|
|
|
if [ ! -f "$header_file" ]; then |
|
|
|
echo "Warning: No header file found for ${module_name}, skipping" |
|
|
|
echo "Warning: No header file found for ${module_name}, skipping" |
|
|
|
return |
|
|
|
return |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if ! needs_update "$header_file" "$output_file"; then |
|
|
|
|
|
|
|
echo "----------" |
|
|
|
|
|
|
|
echo "Skipping ${module_name} (up to date)" |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "----------" |
|
|
|
echo "----------" |
|
|
|
echo "Processing ${module_name}..." |
|
|
|
echo "Processing ${module_name}..." |
|
|
|
|
|
|
|
|
|
|
|
local CMD=() |
|
|
|
# Build command as array |
|
|
|
CMD+=("pi" "--print" "--no-session" "--provider" "$LLM_PROVIDER" "--model" "$LLM_MODEL") |
|
|
|
CMD=() |
|
|
|
|
|
|
|
CMD+=("pi" "--print" "--no-session" "--provider" "llama.cpp" "--model" "Qwen3.6-35B") |
|
|
|
CMD+=("$(generate_prompt "$module_name")") |
|
|
|
CMD+=("$(generate_prompt "$module_name")") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#echo "CMD would execute: ${CMD[*]}" |
|
|
|
"${CMD[@]}" |
|
|
|
"${CMD[@]}" |
|
|
|
echo "Generated: ${output_file}" |
|
|
|
echo "Generated: ${output_file}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Combine all per-module summaries into a single file |
|
|
|
# List of modules to process (based on src/ directory) |
|
|
|
combine_summaries() { |
|
|
|
# Modules to exclude from processing |
|
|
|
local output_file="${SUMMARY_DIR}/all_summaries.md" |
|
|
|
EXCLUDED=("renderer" "ui_renderer" "config_validator") |
|
|
|
echo "Combining summaries into ${output_file}..." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "# Combined Interface Summaries" > "$output_file" |
|
|
|
# Filter function |
|
|
|
echo "" >> "$output_file" |
|
|
|
is_excluded() { |
|
|
|
echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')" >> "$output_file" |
|
|
|
local mod="$1" |
|
|
|
echo "" >> "$output_file" |
|
|
|
for exc in "${EXCLUDED[@]}"; do |
|
|
|
|
|
|
|
[[ "$mod" == "$exc" ]] && return 0 |
|
|
|
for module in "${MODULES[@]}"; do |
|
|
|
|
|
|
|
local summary_file="${SUMMARY_DIR}/${module}${TEMP_EXT}" |
|
|
|
|
|
|
|
if [ -f "$summary_file" ]; then |
|
|
|
|
|
|
|
echo "" >> "$output_file" |
|
|
|
|
|
|
|
echo "---" >> "$output_file" |
|
|
|
|
|
|
|
echo "" >> "$output_file" |
|
|
|
|
|
|
|
cat "$summary_file" >> "$output_file" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
return 1 |
|
|
|
echo "Combined ${#MODULES[@]} summaries into ${output_file}" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Main execution |
|
|
|
# Build filtered list |
|
|
|
|
|
|
|
MODULES=() |
|
|
|
|
|
|
|
for h in src/*.h; do |
|
|
|
|
|
|
|
mod=$(basename "$h" .h) |
|
|
|
|
|
|
|
is_excluded "$mod" || MODULES+=("$mod") |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
echo "=== Interface Summary Generator ===" |
|
|
|
echo "=== Interface Summary Generator ===" |
|
|
|
echo "Processing ${#MODULES[@]} modules..." |
|
|
|
echo "Processing ${#MODULES[@]} modules..." |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$SUMMARY_DIR" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for module in "${MODULES[@]}"; do |
|
|
|
for module in "${MODULES[@]}"; do |
|
|
|
process_module "$module" |
|
|
|
process_module "$module" |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
echo "=== Complete ===" |
|
|
|
echo "=== Complete ===" |
|
|
|
echo "Generated ${TEMP_EXT} files in ${SUMMARY_DIR}" |
|
|
|
echo "Generated ${TEMP_EXT} files alongside source files in ${SRC_DIR}" |
|
|
|
echo "These files are temporary and should be added to .gitignore" |
|
|
|
echo "These files are temporary and should be added to .gitignore" |
|
|
|
|
|
|
|
|
|
|
|
combine_summaries |
|
|
|
|
|
|
|
|