Compare commits

...

3 Commits

Author SHA1 Message Date
cinnaboot 7c3142788b update TODO, move doc generation to ./tmp/ 3 months ago
cinnaboot dec5cc4fee Move summaries to tmp/summaries with cache and combine support 3 months ago
cinnaboot 3376737150 remove clean-all make target 3 months ago
  1. 2
      .gitignore
  2. 5
      Makefile
  3. 2
      docs/TODO
  4. 96
      scripts/generate_interface_summaries.sh
  5. 2
      scripts/prompt.md

2
.gitignore vendored

@ -6,7 +6,7 @@ orbit_test
tests/informational/test_time_step_stability tests/informational/test_time_step_stability
# LLM summaries # LLM summaries
src/*.summary.md tmp/
# Session notes and conversation logs # Session notes and conversation logs
docs/session_logs docs/session_logs

5
Makefile

@ -49,9 +49,6 @@ clean:
rm -rf $(BUILD_DIR) $(LIBRARY) rm -rf $(BUILD_DIR) $(LIBRARY)
$(MAKE) -C example clean $(MAKE) -C example clean
clean-all: clean
$(MAKE) -C example clean-all
rebuild: clean all rebuild: clean all
.PHONY: all lib test-build test example clean clean-all rebuild .PHONY: all lib test-build test example clean rebuild

2
docs/TODO

@ -17,10 +17,8 @@ If you see modifications to this file in git status, IGNORE them and do not comm
- add reset/load new config UI control - add reset/load new config UI control
- UI fixes - UI fixes
- add more documentation for the LLM to use 'make test-build' and run individual tests
- write out/fix inline code docs with the documentation generation script, and review - write out/fix inline code docs with the documentation generation script, and review
- can then work on a better method for commenting/detecting changes via script - can then work on a better method for commenting/detecting changes via script
- move summary docs to separate folder and combine into a big 'API reference' doc
=== Project Documentation === === Project Documentation ===

96
scripts/generate_interface_summaries.sh

@ -1,72 +1,116 @@
#!/bin/bash #!/bin/bash
# Generate interface summaries for all modules in src/ # Generate interface summaries for all modules in src/
# Creates temporary markdown files alongside source files for quick reference # Outputs to tmp/summaries/ (per-module cache) and supports combining into one file
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"
# Function to generate prompt for a specific module # Discover modules from src/ directory
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|\${SRC_DIR}|$SRC_DIR|g" sed "s|\${module_name}|$module_name|g" "$PROMPT_FILE" \
| sed "s|\${SRC_DIR}|$SRC_DIR|g" \
| sed "s|\${SUMMARY_DIR}|$SUMMARY_DIR|g"
} }
# Function to process a single module # Check if summary needs regeneration based on file timestamps
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="${SRC_DIR}/${module_name}${TEMP_EXT}" local output_file="${SUMMARY_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}..."
# Build command as array local CMD=()
CMD=() CMD+=("pi" "--print" "--no-session" "--provider" "$LLM_PROVIDER" "--model" "$LLM_MODEL")
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}"
} }
# List of modules to process (based on src/ directory) # Combine all per-module summaries into a single file
# Modules to exclude from processing combine_summaries() {
EXCLUDED=("renderer" "ui_renderer" "config_validator") local output_file="${SUMMARY_DIR}/all_summaries.md"
echo "Combining summaries into ${output_file}..."
# Filter function echo "# Combined Interface Summaries" > "$output_file"
is_excluded() { echo "" >> "$output_file"
local mod="$1" echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')" >> "$output_file"
for exc in "${EXCLUDED[@]}"; do echo "" >> "$output_file"
[[ "$mod" == "$exc" ]] && return 0
done
return 1
}
# Build filtered list for module in "${MODULES[@]}"; do
MODULES=() local summary_file="${SUMMARY_DIR}/${module}${TEMP_EXT}"
for h in src/*.h; do if [ -f "$summary_file" ]; then
mod=$(basename "$h" .h) echo "" >> "$output_file"
is_excluded "$mod" || MODULES+=("$mod") echo "---" >> "$output_file"
echo "" >> "$output_file"
cat "$summary_file" >> "$output_file"
fi
done done
echo "Combined ${#MODULES[@]} summaries into ${output_file}"
}
# Main execution
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 alongside source files in ${SRC_DIR}" echo "Generated ${TEMP_EXT} files in ${SUMMARY_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

2
scripts/prompt.md

@ -35,4 +35,4 @@ static const <type> <CONSTANT_NAME> = <value>; // or inline (if needed)
Keep summaries concise but do not oversimplify complex algorithms - include enough detail Keep summaries concise but do not oversimplify complex algorithms - include enough detail
to understand the logic and approach. Focus on public interfaces, not internal implementation details. to understand the logic and approach. Focus on public interfaces, not internal implementation details.
IMPORTANT: write output to one file alongside the module location: ${SRC_DIR}/${module_name}.summary.md IMPORTANT: write output to one file: ${SUMMARY_DIR}/${module_name}.summary.md

Loading…
Cancel
Save