From 4c9b5d1c7c44436275e7d318e8c2dea0276f4b7e Mon Sep 17 00:00:00 2001 From: fujie Date: Sat, 21 Mar 2026 12:21:20 +0800 Subject: [PATCH] feat(github-copilot-sdk): auto-init interactive_controls table and inject schema and rules into prompt --- .../github-copilot-sdk/github_copilot_sdk.py | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py index b258208..bc2b1aa 100644 --- a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py +++ b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py @@ -5614,6 +5614,29 @@ class Pipe: os.makedirs(path, exist_ok=True) return path + def _initialize_interactive_controls_table(self, chat_id: str) -> None: + """Initialize the interactive_controls table in session.db if not exists.""" + if not chat_id: + return + try: + metadata_dir = self._get_session_metadata_dir(chat_id) + db_path = os.path.join(metadata_dir, "session.db") + import sqlite3 + with sqlite3.connect(db_path) as conn: + conn.execute(""" + CREATE TABLE IF NOT EXISTS interactive_controls ( + id TEXT PRIMARY KEY, + label TEXT NOT NULL, + action TEXT NOT NULL, + status TEXT DEFAULT 'visible', + likelihood REAL DEFAULT 0.5, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP + ) + """) + except Exception as e: + logger.warning(f"Failed to initialize interactive_controls table for {chat_id}: {e}") + def _get_plan_file_path(self, chat_id: Optional[str]) -> Optional[str]: """Return the canonical plan.md path for the current chat session.""" if not chat_id: @@ -6783,12 +6806,14 @@ class Pipe: adaptive_console_note = ( "\n[Adaptive Interactive Console Guidelines]\n" - "Your generated views (e.g., `