3rd commit
This commit is contained in:
53
script/fix_and_explain_strudel.sh
Normal file
53
script/fix_and_explain_strudel.sh
Normal 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
|
||||
39
script/organize_strudel.sh
Normal file
39
script/organize_strudel.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# スクリプトの場所 (scripts/) からプロジェクトルートを動的に取得
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
BASE_DIR="$ROOT_DIR/organized_strudel"
|
||||
SOURCE_DIR="$ROOT_DIR/strudel"
|
||||
|
||||
mkdir -p "$BASE_DIR"
|
||||
|
||||
echo "Starting Strudel code categorization..."
|
||||
|
||||
for file in "$SOURCE_DIR"/*.md; do
|
||||
# ドキュメントファイル自体は除外
|
||||
[[ "$file" == *"Strudel Making Sound.md"* ]] && continue
|
||||
[[ "$file" == *"Strudel Study.md"* ]] && continue
|
||||
[[ "$file" == *"/script/"* ]] && continue
|
||||
[ -e "$file" ] || continue
|
||||
|
||||
filename=$(basename "$file")
|
||||
echo "Analyzing $filename..."
|
||||
|
||||
# gemini-cli を使用してカテゴリを判定
|
||||
category=$(cat "$file" | gemini-cli "Analyze this Strudel code.
|
||||
Based on functions like s(), note(), fm(), degrade(), or effects like lpf(),
|
||||
classify this into exactly one of these categories:
|
||||
'Sampling', 'Synthesis', 'Generative', 'Ambient_FX'.
|
||||
Return only the category name as a single word.")
|
||||
|
||||
# カテゴリが取得できなかった場合のデフォルト
|
||||
if [ -z "$category" ]; then
|
||||
category="Unclassified"
|
||||
fi
|
||||
|
||||
target_path="$BASE_DIR/$category"
|
||||
mkdir -p "$target_path"
|
||||
|
||||
cp "$file" "$target_path/"
|
||||
echo "-> Moved to $category/"
|
||||
done
|
||||
52
script/refactor_strudel.sh
Normal file
52
script/refactor_strudel.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# スクリプトの場所 (scripts/) からプロジェクトルート (notebook/) を動的に取得
|
||||
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
REFACTOR_DIR="$BASE_DIR/refactoring"
|
||||
SKILL_FILE="$BASE_DIR/.gemini/skills/strudel_refactor.md"
|
||||
|
||||
# 出力先フォルダの作成
|
||||
mkdir -p "$REFACTOR_DIR"
|
||||
|
||||
# 引数がある場合はそれを使用し、ない場合は strudel/ フォルダの全mdファイルを対象にする
|
||||
if [ $# -gt 0 ]; then
|
||||
files=("$@")
|
||||
else
|
||||
files=("$BASE_DIR/strudel"/*.md)
|
||||
fi
|
||||
|
||||
echo "Strudel Code Analysis & Refactoring Skill started..."
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
# 除外設定
|
||||
[[ "$file" == *"Strudel Making Sound.md"* ]] && continue
|
||||
[[ "$file" == *"Strudel Study.md"* ]] && continue
|
||||
[[ "$file" == *"/refactoring/"* ]] && continue
|
||||
[[ "$file" == *"/scripts/"* ]] && continue
|
||||
[ -f "$file" ] || continue
|
||||
|
||||
filename=$(basename "$file")
|
||||
echo "Processing $filename..."
|
||||
|
||||
# スキルファイルをシステムプロンプトとして使用
|
||||
tmp_file="$REFACTOR_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行目(FILENAME行)を除去してリネーム保存
|
||||
tail -n +2 "$tmp_file" > "$REFACTOR_DIR/$suggested_name"
|
||||
rm "$tmp_file"
|
||||
echo "Successfully refactored and renamed to: $suggested_name"
|
||||
else
|
||||
mv "$tmp_file" "$REFACTOR_DIR/$filename"
|
||||
echo "Successfully refactored: $filename (Rename tag not found)"
|
||||
fi
|
||||
else
|
||||
rm -f "$tmp_file"
|
||||
echo "Error processing $filename"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user