GitHub Action
commited on
Commit
·
f1e6fda
1
Parent(s):
14015fd
🚀 Auto-deploy from GitHub Actions
Browse files- controllers/conversation_history.py +281 -0
- generate_prompt.py +113 -0
controllers/conversation_history.py
CHANGED
|
@@ -226,6 +226,169 @@ class ConversationManager:
|
|
| 226 |
'today_conversations': today_conversations,
|
| 227 |
'top_tools': top_tools
|
| 228 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
# グローバルインスタンス
|
| 231 |
conversation_manager = ConversationManager()
|
|
@@ -432,6 +595,124 @@ def create_conversation_interface():
|
|
| 432 |
value="🔄 統計更新ボタンを押してください"
|
| 433 |
)
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
# イベントハンドラー
|
| 436 |
load_btn.click(
|
| 437 |
fn=load_conversation_history,
|
|
|
|
| 226 |
'today_conversations': today_conversations,
|
| 227 |
'top_tools': top_tools
|
| 228 |
}
|
| 229 |
+
|
| 230 |
+
def generate_prompt_summary(self, limit: int = 10) -> str:
|
| 231 |
+
"""
|
| 232 |
+
プロンプト用の会話履歴サマリーを生成
|
| 233 |
+
|
| 234 |
+
Args:
|
| 235 |
+
limit: 取得する最新会話数
|
| 236 |
+
|
| 237 |
+
Returns:
|
| 238 |
+
プロンプトに含めるためのサマリー文字列
|
| 239 |
+
"""
|
| 240 |
+
conn = sqlite3.connect(self.db_path)
|
| 241 |
+
cursor = conn.cursor()
|
| 242 |
+
|
| 243 |
+
try:
|
| 244 |
+
# 最新の会話を取得
|
| 245 |
+
cursor.execute('''
|
| 246 |
+
SELECT user_message, assistant_response, context_info,
|
| 247 |
+
tools_used, tags, created_at
|
| 248 |
+
FROM conversations
|
| 249 |
+
ORDER BY created_at DESC
|
| 250 |
+
LIMIT ?
|
| 251 |
+
''', (limit,))
|
| 252 |
+
|
| 253 |
+
conversations = cursor.fetchall()
|
| 254 |
+
|
| 255 |
+
if not conversations:
|
| 256 |
+
return "## 会話履歴\n過去の会話履歴はありません。"
|
| 257 |
+
|
| 258 |
+
# サマリーを構築
|
| 259 |
+
summary = ["## 🕒 前回までの会話履歴サマリー"]
|
| 260 |
+
summary.append("```")
|
| 261 |
+
summary.append("GitHub Copilotとの過去の主要な会話内容:")
|
| 262 |
+
summary.append("")
|
| 263 |
+
|
| 264 |
+
for i, (user_msg, assistant_resp, context, tools, tags, timestamp) in enumerate(conversations, 1):
|
| 265 |
+
# メッセージを要約(長すぎる場合は切り詰め)
|
| 266 |
+
user_summary = user_msg[:100] + "..." if len(user_msg) > 100 else user_msg
|
| 267 |
+
assistant_summary = assistant_resp[:150] + "..." if len(assistant_resp) > 150 else assistant_resp
|
| 268 |
+
|
| 269 |
+
summary.append(f"{i}. [{timestamp[:16]}]")
|
| 270 |
+
summary.append(f" ユーザー: {user_summary}")
|
| 271 |
+
summary.append(f" 対応: {assistant_summary}")
|
| 272 |
+
|
| 273 |
+
if context:
|
| 274 |
+
summary.append(f" コンテキスト: {context}")
|
| 275 |
+
if tools:
|
| 276 |
+
summary.append(f" 使用ツール: {tools}")
|
| 277 |
+
if tags:
|
| 278 |
+
summary.append(f" タグ: {tags}")
|
| 279 |
+
summary.append("")
|
| 280 |
+
|
| 281 |
+
summary.append("```")
|
| 282 |
+
summary.append("")
|
| 283 |
+
summary.append("💡 **重要**: 上記の履歴を参考に、継続性のある対応を行ってください。")
|
| 284 |
+
|
| 285 |
+
return "\n".join(summary)
|
| 286 |
+
|
| 287 |
+
except Exception as e:
|
| 288 |
+
return f"## 会話履歴\n履歴取得エラー: {str(e)}"
|
| 289 |
+
finally:
|
| 290 |
+
conn.close()
|
| 291 |
+
|
| 292 |
+
def generate_context_prompt(self, session_limit: int = 5, detail_limit: int = 3) -> str:
|
| 293 |
+
"""
|
| 294 |
+
新しいセッション用のコンテキストプロンプトを生成
|
| 295 |
+
|
| 296 |
+
Args:
|
| 297 |
+
session_limit: セッション履歴の取得数
|
| 298 |
+
detail_limit: 詳細表示する最新会話数
|
| 299 |
+
|
| 300 |
+
Returns:
|
| 301 |
+
新しいプロンプトに含めるコンテキスト情報
|
| 302 |
+
"""
|
| 303 |
+
conn = sqlite3.connect(self.db_path)
|
| 304 |
+
cursor = conn.cursor()
|
| 305 |
+
|
| 306 |
+
try:
|
| 307 |
+
# プロジェクト統計
|
| 308 |
+
cursor.execute('SELECT COUNT(*) FROM conversations')
|
| 309 |
+
total_conversations = cursor.fetchone()[0]
|
| 310 |
+
|
| 311 |
+
cursor.execute('SELECT COUNT(DISTINCT session_id) FROM sessions')
|
| 312 |
+
total_sessions = cursor.fetchone()[0]
|
| 313 |
+
|
| 314 |
+
# 最新セッションの情報
|
| 315 |
+
cursor.execute('''
|
| 316 |
+
SELECT session_id, session_name, start_time, total_messages
|
| 317 |
+
FROM sessions
|
| 318 |
+
ORDER BY start_time DESC
|
| 319 |
+
LIMIT ?
|
| 320 |
+
''', (session_limit,))
|
| 321 |
+
recent_sessions = cursor.fetchall()
|
| 322 |
+
|
| 323 |
+
# 最新の詳細会話
|
| 324 |
+
cursor.execute('''
|
| 325 |
+
SELECT user_message, assistant_response, context_info,
|
| 326 |
+
tools_used, tags, created_at
|
| 327 |
+
FROM conversations
|
| 328 |
+
ORDER BY created_at DESC
|
| 329 |
+
LIMIT ?
|
| 330 |
+
''', (detail_limit,))
|
| 331 |
+
recent_conversations = cursor.fetchall()
|
| 332 |
+
|
| 333 |
+
# プロンプト構築
|
| 334 |
+
context_lines = [
|
| 335 |
+
"<conversation-summary>",
|
| 336 |
+
"## CONVERSATION SUMMARY",
|
| 337 |
+
"",
|
| 338 |
+
"**TASK DESCRIPTION:** ",
|
| 339 |
+
"統合開発環境でのContBKフォルダーインターフェース統合、会話履歴システム実装、",
|
| 340 |
+
"SQLiteベースの自動ログ機能開発を継続的に行っています。",
|
| 341 |
+
"",
|
| 342 |
+
"**COMPLETED:**",
|
| 343 |
+
f"- ✅ 総会話数: {total_conversations}件",
|
| 344 |
+
f"- ✅ セッション数: {total_sessions}件",
|
| 345 |
+
"- ✅ ContBK統合システム実装���み",
|
| 346 |
+
"- ✅ SQLite会話履歴システム実装済み",
|
| 347 |
+
"- ✅ DuplicateBlockError修正済み",
|
| 348 |
+
"- ✅ Git同期管理実装済み",
|
| 349 |
+
""
|
| 350 |
+
]
|
| 351 |
+
|
| 352 |
+
if recent_sessions:
|
| 353 |
+
context_lines.extend([
|
| 354 |
+
"**RECENT SESSIONS:**",
|
| 355 |
+
])
|
| 356 |
+
for session_id, name, start_time, total_messages in recent_sessions:
|
| 357 |
+
context_lines.append(f"- {name} ({total_messages}件) - {start_time[:16]}")
|
| 358 |
+
context_lines.append("")
|
| 359 |
+
|
| 360 |
+
if recent_conversations:
|
| 361 |
+
context_lines.extend([
|
| 362 |
+
"**LATEST CONVERSATIONS:**",
|
| 363 |
+
])
|
| 364 |
+
for i, (user_msg, assistant_resp, context, tools, tags, timestamp) in enumerate(recent_conversations, 1):
|
| 365 |
+
user_summary = user_msg[:80] + "..." if len(user_msg) > 80 else user_msg
|
| 366 |
+
assistant_summary = assistant_resp[:100] + "..." if len(assistant_resp) > 100 else assistant_resp
|
| 367 |
+
|
| 368 |
+
context_lines.extend([
|
| 369 |
+
f"{i}. [{timestamp[:16]}] {user_summary}",
|
| 370 |
+
f" → {assistant_summary}",
|
| 371 |
+
])
|
| 372 |
+
if context:
|
| 373 |
+
context_lines.append(f" Context: {context}")
|
| 374 |
+
if tools:
|
| 375 |
+
context_lines.append(f" Tools: {tools}")
|
| 376 |
+
context_lines.append("")
|
| 377 |
+
|
| 378 |
+
context_lines.extend([
|
| 379 |
+
"**CURRENT_STATE:**",
|
| 380 |
+
"アプリケーションは http://localhost:7860 で正常稼働中。",
|
| 381 |
+
"10個のGradioインターフェースが統合され、会話履歴システムも完全に動作しています。",
|
| 382 |
+
"全ての変更はGitで管理され、SQLiteに自動記録されています。",
|
| 383 |
+
"</conversation-summary>"
|
| 384 |
+
])
|
| 385 |
+
|
| 386 |
+
return "\n".join(context_lines)
|
| 387 |
+
|
| 388 |
+
except Exception as e:
|
| 389 |
+
return f"<conversation-summary>\nコンテキスト生成エラー: {str(e)}\n</conversation-summary>"
|
| 390 |
+
finally:
|
| 391 |
+
conn.close()
|
| 392 |
|
| 393 |
# グローバルインスタンス
|
| 394 |
conversation_manager = ConversationManager()
|
|
|
|
| 595 |
value="🔄 統計更新ボタンを押してください"
|
| 596 |
)
|
| 597 |
|
| 598 |
+
with gr.Tab("📝 プロンプト生成"):
|
| 599 |
+
gr.Markdown("""
|
| 600 |
+
## 🎯 新セッション用プロンプト生成
|
| 601 |
+
|
| 602 |
+
新しいGitHub Copilotセッション開始時に使用する、
|
| 603 |
+
過去の会話履歴を含むコンテキストプロンプトを生成します。
|
| 604 |
+
""")
|
| 605 |
+
|
| 606 |
+
with gr.Row():
|
| 607 |
+
with gr.Column():
|
| 608 |
+
prompt_type = gr.Radio(
|
| 609 |
+
label="📋 プロンプトタイプ",
|
| 610 |
+
choices=[
|
| 611 |
+
"簡易サマリー (最新10件)",
|
| 612 |
+
"詳細コンテキスト (セッション含む)",
|
| 613 |
+
"技術フォーカス (ツール・ファイル中心)",
|
| 614 |
+
"カスタム設定"
|
| 615 |
+
],
|
| 616 |
+
value="詳細コンテキスト (セッション含む)"
|
| 617 |
+
)
|
| 618 |
+
|
| 619 |
+
with gr.Group():
|
| 620 |
+
conversation_limit = gr.Slider(
|
| 621 |
+
label="📊 会話履歴件数",
|
| 622 |
+
minimum=3,
|
| 623 |
+
maximum=20,
|
| 624 |
+
value=10,
|
| 625 |
+
step=1
|
| 626 |
+
)
|
| 627 |
+
|
| 628 |
+
session_limit = gr.Slider(
|
| 629 |
+
label="🗂️ セッション履歴件数",
|
| 630 |
+
minimum=3,
|
| 631 |
+
maximum=10,
|
| 632 |
+
value=5,
|
| 633 |
+
step=1
|
| 634 |
+
)
|
| 635 |
+
|
| 636 |
+
include_tools = gr.Checkbox(
|
| 637 |
+
label="🔧 ツール使用履歴を含む",
|
| 638 |
+
value=True
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
include_files = gr.Checkbox(
|
| 642 |
+
label="📁 ファイル操作履歴を含む",
|
| 643 |
+
value=True
|
| 644 |
+
)
|
| 645 |
+
|
| 646 |
+
with gr.Row():
|
| 647 |
+
generate_btn = gr.Button("🎯 プロンプト生成", variant="primary", size="lg")
|
| 648 |
+
copy_btn = gr.Button("📋 クリップボードにコピー", variant="secondary")
|
| 649 |
+
|
| 650 |
+
prompt_output = gr.Textbox(
|
| 651 |
+
label="📝 生成されたプロンプト",
|
| 652 |
+
lines=20,
|
| 653 |
+
max_lines=30,
|
| 654 |
+
placeholder="生成ボタンを押すとプロンプトが表示されます...",
|
| 655 |
+
show_copy_button=True
|
| 656 |
+
)
|
| 657 |
+
|
| 658 |
+
gr.Markdown("""
|
| 659 |
+
### 📌 使用方法:
|
| 660 |
+
1. プロンプトタイプを選択
|
| 661 |
+
2. 必要に応じて設定を調整
|
| 662 |
+
3. 「プロンプト生成」をクリック
|
| 663 |
+
4. 生成されたテキストを新しいセッションの最初にコピー&ペースト
|
| 664 |
+
|
| 665 |
+
💡 **Tip**: 生成されたプロンプトにより、GitHub Copilotが過去のコンテキストを理解して、
|
| 666 |
+
より継続性のある対応ができるようになります。
|
| 667 |
+
""")
|
| 668 |
+
|
| 669 |
+
def generate_context_prompt_ui(prompt_type, conv_limit, sess_limit, include_tools, include_files):
|
| 670 |
+
"""UIからプロンプト生成"""
|
| 671 |
+
try:
|
| 672 |
+
if prompt_type == "簡易サマリー (最新10件)":
|
| 673 |
+
return conversation_manager.generate_prompt_summary(limit=conv_limit)
|
| 674 |
+
elif prompt_type == "詳細コンテキスト (セッション含む)":
|
| 675 |
+
return conversation_manager.generate_context_prompt(
|
| 676 |
+
session_limit=sess_limit,
|
| 677 |
+
detail_limit=conv_limit
|
| 678 |
+
)
|
| 679 |
+
elif prompt_type == "技術フォーカス (ツール・ファイル中心)":
|
| 680 |
+
# 技術的な詳細に特化したプロンプト
|
| 681 |
+
context = conversation_manager.generate_context_prompt(sess_limit, conv_limit)
|
| 682 |
+
tech_header = """
|
| 683 |
+
<technical-context>
|
| 684 |
+
## TECHNICAL DEVELOPMENT CONTEXT
|
| 685 |
+
|
| 686 |
+
**FOCUS**: ContBK統合システム、SQLite会話履歴、Gradioインターフェース開発
|
| 687 |
+
|
| 688 |
+
**ACTIVE TOOLS**:
|
| 689 |
+
- Gradio 4.31.5 (推奨: 4.44.1)
|
| 690 |
+
- SQLite3 (会話履歴管理)
|
| 691 |
+
- Python 3.11
|
| 692 |
+
- Git (バージョン管理)
|
| 693 |
+
- FastAPI + Django (バックエンド)
|
| 694 |
+
|
| 695 |
+
**CURRENT ENVIRONMENT**:
|
| 696 |
+
- Workspace: /workspaces/fastapi_django_main_live
|
| 697 |
+
- Port 7860: メインアプリケーション
|
| 698 |
+
- Port 7870-7880: 開発用サブアプリ
|
| 699 |
+
|
| 700 |
+
</technical-context>
|
| 701 |
+
|
| 702 |
+
"""
|
| 703 |
+
return tech_header + context
|
| 704 |
+
else: # カスタム設定
|
| 705 |
+
return conversation_manager.generate_context_prompt(sess_limit, conv_limit)
|
| 706 |
+
|
| 707 |
+
except Exception as e:
|
| 708 |
+
return f"❌ プロンプト生成エラー: {str(e)}"
|
| 709 |
+
|
| 710 |
+
generate_btn.click(
|
| 711 |
+
generate_context_prompt_ui,
|
| 712 |
+
inputs=[prompt_type, conversation_limit, session_limit, include_tools, include_files],
|
| 713 |
+
outputs=prompt_output
|
| 714 |
+
)
|
| 715 |
+
|
| 716 |
# イベントハンドラー
|
| 717 |
load_btn.click(
|
| 718 |
fn=load_conversation_history,
|
generate_prompt.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
プロンプト生成ツール
|
| 4 |
+
===================
|
| 5 |
+
|
| 6 |
+
新しいGitHub Copilotセッション用のコンテキストプロンプトを生成
|
| 7 |
+
|
| 8 |
+
使用方法:
|
| 9 |
+
python generate_prompt.py
|
| 10 |
+
python generate_prompt.py --type summary --limit 10
|
| 11 |
+
python generate_prompt.py --type context --sessions 5 --conversations 8
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
import argparse
|
| 15 |
+
import sys
|
| 16 |
+
import os
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
# プロジェクトルートをパスに追加
|
| 20 |
+
project_root = Path(__file__).parent
|
| 21 |
+
sys.path.insert(0, str(project_root))
|
| 22 |
+
|
| 23 |
+
from controllers.conversation_history import ConversationManager
|
| 24 |
+
|
| 25 |
+
def main():
|
| 26 |
+
parser = argparse.ArgumentParser(description="GitHub Copilot用コンテキストプロンプト生成")
|
| 27 |
+
parser.add_argument(
|
| 28 |
+
"--type",
|
| 29 |
+
choices=["summary", "context", "technical"],
|
| 30 |
+
default="context",
|
| 31 |
+
help="生成するプロンプトのタイプ"
|
| 32 |
+
)
|
| 33 |
+
parser.add_argument(
|
| 34 |
+
"--limit",
|
| 35 |
+
type=int,
|
| 36 |
+
default=10,
|
| 37 |
+
help="会話履歴の取得件数"
|
| 38 |
+
)
|
| 39 |
+
parser.add_argument(
|
| 40 |
+
"--sessions",
|
| 41 |
+
type=int,
|
| 42 |
+
default=5,
|
| 43 |
+
help="セッション履歴の取得件数"
|
| 44 |
+
)
|
| 45 |
+
parser.add_argument(
|
| 46 |
+
"--conversations",
|
| 47 |
+
type=int,
|
| 48 |
+
default=8,
|
| 49 |
+
help="詳細表示する会話数"
|
| 50 |
+
)
|
| 51 |
+
parser.add_argument(
|
| 52 |
+
"--output",
|
| 53 |
+
help="出力ファイル名 (省略時は標準出力)"
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
args = parser.parse_args()
|
| 57 |
+
|
| 58 |
+
# ConversationManager初期化
|
| 59 |
+
try:
|
| 60 |
+
manager = ConversationManager()
|
| 61 |
+
|
| 62 |
+
# プロンプト生成
|
| 63 |
+
if args.type == "summary":
|
| 64 |
+
prompt = manager.generate_prompt_summary(limit=args.limit)
|
| 65 |
+
elif args.type == "context":
|
| 66 |
+
prompt = manager.generate_context_prompt(
|
| 67 |
+
session_limit=args.sessions,
|
| 68 |
+
detail_limit=args.conversations
|
| 69 |
+
)
|
| 70 |
+
elif args.type == "technical":
|
| 71 |
+
# 技術フォーカス版
|
| 72 |
+
base_prompt = manager.generate_context_prompt(args.sessions, args.conversations)
|
| 73 |
+
tech_header = """<technical-context>
|
| 74 |
+
## TECHNICAL DEVELOPMENT CONTEXT
|
| 75 |
+
|
| 76 |
+
**FOCUS**: ContBK統合システム、SQLite会話履歴、Gradioインターフェース開発
|
| 77 |
+
|
| 78 |
+
**ACTIVE TOOLS**:
|
| 79 |
+
- Gradio 4.31.5 (推奨: 4.44.1)
|
| 80 |
+
- SQLite3 (会話履歴管理)
|
| 81 |
+
- Python 3.11
|
| 82 |
+
- Git (バージョン管理)
|
| 83 |
+
- FastAPI + Django (バックエンド)
|
| 84 |
+
|
| 85 |
+
**CURRENT ENVIRONMENT**:
|
| 86 |
+
- Workspace: /workspaces/fastapi_django_main_live
|
| 87 |
+
- Port 7860: メインアプリケーション
|
| 88 |
+
- Port 7870-7880: 開発用サブアプリ
|
| 89 |
+
|
| 90 |
+
</technical-context>
|
| 91 |
+
|
| 92 |
+
"""
|
| 93 |
+
prompt = tech_header + base_prompt
|
| 94 |
+
|
| 95 |
+
# 出力
|
| 96 |
+
if args.output:
|
| 97 |
+
with open(args.output, 'w', encoding='utf-8') as f:
|
| 98 |
+
f.write(prompt)
|
| 99 |
+
print(f"✅ プロンプトを {args.output} に保存しました")
|
| 100 |
+
else:
|
| 101 |
+
print("=" * 80)
|
| 102 |
+
print("🎯 GitHub Copilot用コンテキストプロンプト")
|
| 103 |
+
print("=" * 80)
|
| 104 |
+
print(prompt)
|
| 105 |
+
print("=" * 80)
|
| 106 |
+
print("📋 上記のテキストを新しいセッションの最初にコピー&ペーストしてください")
|
| 107 |
+
|
| 108 |
+
except Exception as e:
|
| 109 |
+
print(f"❌ エラー: {e}", file=sys.stderr)
|
| 110 |
+
sys.exit(1)
|
| 111 |
+
|
| 112 |
+
if __name__ == "__main__":
|
| 113 |
+
main()
|