41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# collection_flutter_code.py
|
|
# Version: 1.0.0 (2025-07-04)
|
|
# Description: Flutterのlib配下のコードを集約し、AIへの受け渡しを最適化する
|
|
|
|
import os
|
|
|
|
def collect_flutter_code(target_dir='lib', output_file='flutter_bundle_for_ai.txt'):
|
|
# AIが識別しやすいようにヘッダーを付与
|
|
header = """
|
|
# ==========================================
|
|
# FLUTTER CODE BUNDLE FOR AI ANALYSIS
|
|
# PROJECT: Flutter to Kivy Migration
|
|
# ==========================================
|
|
"""
|
|
|
|
collected_data = [header]
|
|
|
|
if not os.path.exists(target_dir):
|
|
print(f"Error: {target_dir} ディレクトリが見つかりません。")
|
|
return
|
|
|
|
for root, dirs, files in os.walk(target_dir):
|
|
for file in files:
|
|
if file.endswith('.dart'):
|
|
file_path = os.path.join(root, file)
|
|
relative_path = os.path.relpath(file_path, target_dir)
|
|
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
# AIにファイル構造を理解させるためのデリミタ
|
|
collected_data.append(f"\n\n--- FILE: {relative_path} ---")
|
|
collected_data.append(content)
|
|
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
f.write("\n".join(collected_data))
|
|
|
|
print(f"成功: {output_file} に全コードを回収しました。")
|
|
print("このファイルの内容をコピーして、私に貼り付けてください。")
|
|
|
|
if __name__ == "__main__":
|
|
collect_flutter_code()
|