3rd commit

This commit is contained in:
HarakaraSite
2026-02-11 21:26:03 +09:00
parent c08ce0cee4
commit 0be0a702c9
7 changed files with 218 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# スクリプトの場所 (scripts/) からプロジェクトルート (notebook/) を動的に取得
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
OUTPUT_DIR="$BASE_DIR/explained"
SKILL_FILE="$BASE_DIR/.gemini/skills/strudel_fix_and_explain.md"
# 出力先フォルダの作成
mkdir -p "$OUTPUT_DIR"
# 引数がある場合はそれを使用し、ない場合は strudel/ フォルダの全mdファイルを対象にする
if [ $# -gt 0 ]; then
files=("$@")
else
files=("$BASE_DIR/strudel"/*.md)
fi
echo "Strudel Fix & Explain Skill started..."
for file in "${files[@]}"; do
# 除外設定
[[ "$file" == *"Strudel Making Sound.md"* ]] && continue
[[ "$file" == *"Strudel Study.md"* ]] && continue
[[ "$file" == *"/refactoring/"* ]] && continue
[[ "$file" == *"/explained/"* ]] && continue
[[ "$file" == *"/script/"* ]] && continue
[ -f "$file" ] || continue
filename=$(basename "$file")
echo "Analyzing and fixing $filename..."
# 一時ファイルに出力
tmp_file="$OUTPUT_DIR/tmp_$filename"
cat "$file" | gemini-cli --system "$(cat "$SKILL_FILE")" > "$tmp_file"
if [ $? -eq 0 ]; then
# 1行目から提案されたファイル名を抽出
suggested_name=$(head -n 1 "$tmp_file" | grep "FILENAME:" | sed 's/FILENAME: //g' | tr -d '\r')
if [ -n "$suggested_name" ]; then
# 1行目を除去して保存
tail -n +2 "$tmp_file" > "$OUTPUT_DIR/$suggested_name"
rm "$tmp_file"
echo "Done: $OUTPUT_DIR/$suggested_name"
else
mv "$tmp_file" "$OUTPUT_DIR/$filename"
echo "Done: $filename (No rename)"
fi
else
rm -f "$tmp_file"
echo "Error processing $filename"
fi
done