57 lines
1.8 KiB
Bash
57 lines
1.8 KiB
Bash
#!/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"
|
|
|
|
# 出力先フォルダの作成
|
|
if [ ! -f "$SKILL_FILE" ]; then
|
|
echo "Error: Skill file not found at $SKILL_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
# 除外設定
|
|
[ -f "$file" ] || continue
|
|
|
|
filename=$(basename "$file")
|
|
# 特定のファイルやディレクトリを除外
|
|
[[ "$filename" =~ ^(Strudel Making Sound|Strudel Study)\.md$ ]] && continue
|
|
[[ "$file" =~ /(refactoring|script|explained|organized_strudel)/ ]] && continue
|
|
|
|
echo "Analyzing and fixing $filename..."
|
|
|
|
# 一時ファイルに出力
|
|
tmp_file="$OUTPUT_DIR/tmp_$filename"
|
|
(cat "$SKILL_FILE"; echo ""; cat "$file") | gemini > "$tmp_file"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
# FILENAME: タグを検索
|
|
suggested_name=$(grep -m 1 "FILENAME:" "$tmp_file" | sed 's/FILENAME: //g' | tr -d '\r')
|
|
|
|
if [ -n "$suggested_name" ]; then
|
|
# FILENAME行を除去して保存
|
|
sed '/FILENAME:/d' "$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 |