commit 7
This commit is contained in:
@@ -6,6 +6,11 @@ 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ファイルを対象にする
|
||||
@@ -19,14 +24,13 @@ 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")
|
||||
# 特定のファイルやディレクトリを除外
|
||||
[[ "$filename" =~ ^(Strudel Making Sound|Strudel Study)\.md$ ]] && continue
|
||||
[[ "$file" =~ /(refactoring|script|explained|organized_strudel)/ ]] && continue
|
||||
|
||||
echo "Analyzing and fixing $filename..."
|
||||
|
||||
# 一時ファイルに出力
|
||||
@@ -34,12 +38,12 @@ for file in "${files[@]}"; do
|
||||
(cat "$SKILL_FILE"; echo ""; cat "$file") | gemini > "$tmp_file"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# 1行目から提案されたファイル名を抽出
|
||||
suggested_name=$(head -n 1 "$tmp_file" | grep "FILENAME:" | sed 's/FILENAME: //g' | tr -d '\r')
|
||||
# FILENAME: タグを検索
|
||||
suggested_name=$(grep -m 1 "FILENAME:" "$tmp_file" | sed 's/FILENAME: //g' | tr -d '\r')
|
||||
|
||||
if [ -n "$suggested_name" ]; then
|
||||
# 1行目を除去して保存
|
||||
tail -n +2 "$tmp_file" > "$OUTPUT_DIR/$suggested_name"
|
||||
# FILENAME行を除去して保存
|
||||
sed '/FILENAME:/d' "$tmp_file" > "$OUTPUT_DIR/$suggested_name"
|
||||
rm "$tmp_file"
|
||||
echo "Done: $OUTPUT_DIR/$suggested_name"
|
||||
else
|
||||
|
||||
@@ -6,6 +6,11 @@ REFACTOR_DIR="$BASE_DIR/refactoring"
|
||||
SKILL_FILE="$BASE_DIR/.gemini/skills/strudel_refactor.md"
|
||||
|
||||
# 出力先フォルダの作成
|
||||
if [ ! -f "$SKILL_FILE" ]; then
|
||||
echo "Error: Skill file not found at $SKILL_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$REFACTOR_DIR"
|
||||
|
||||
# 引数がある場合はそれを使用し、ない場合は strudel/ フォルダの全mdファイルを対象にする
|
||||
@@ -19,13 +24,13 @@ 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" == *"/script/"* ]] && continue
|
||||
[ -f "$file" ] || continue
|
||||
|
||||
|
||||
filename=$(basename "$file")
|
||||
# 特定のファイルやディレクトリを除外
|
||||
[[ "$filename" =~ ^(Strudel Making Sound|Strudel Study)\.md$ ]] && continue
|
||||
[[ "$file" =~ /(refactoring|script|explained|organized_strudel)/ ]] && continue
|
||||
|
||||
echo "Processing $filename..."
|
||||
|
||||
# スキルファイルをシステムプロンプトとして使用
|
||||
@@ -33,12 +38,12 @@ for file in "${files[@]}"; do
|
||||
(cat "$SKILL_FILE"; echo ""; cat "$file") | gemini > "$tmp_file"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# 1行目から提案されたファイル名を抽出
|
||||
suggested_name=$(head -n 1 "$tmp_file" | grep "FILENAME:" | sed 's/FILENAME: //g' | tr -d '\r')
|
||||
# 最初の数行から FILENAME: タグを検索(より柔軟な抽出)
|
||||
suggested_name=$(grep -m 1 "FILENAME:" "$tmp_file" | sed 's/FILENAME: //g' | tr -d '\r')
|
||||
|
||||
if [ -n "$suggested_name" ]; then
|
||||
# 1行目(FILENAME行)を除去してリネーム保存
|
||||
tail -n +2 "$tmp_file" > "$REFACTOR_DIR/$suggested_name"
|
||||
# FILENAME行を除去して保存 (最初の1行目にあると仮定しつつ、sedで安全に削除)
|
||||
sed '/FILENAME:/d' "$tmp_file" > "$REFACTOR_DIR/$suggested_name"
|
||||
rm "$tmp_file"
|
||||
echo "Successfully refactored and renamed to: $suggested_name"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user