socratic-debug 0.0.4__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {socratic_debug-0.0.4/socratic_debug.egg-info → socratic_debug-0.0.6}/PKG-INFO +41 -16
  2. socratic_debug-0.0.6/README.md +150 -0
  3. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/pyproject.toml +2 -1
  4. {socratic_debug-0.0.4 → socratic_debug-0.0.6/socratic_debug.egg-info}/PKG-INFO +41 -16
  5. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/SOURCES.txt +11 -2
  6. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/requires.txt +1 -0
  7. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/factory.py +2 -1
  8. socratic_debug-0.0.6/src/agent/llm/invoker.py +28 -0
  9. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/ollama.py +1 -1
  10. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/diagnose_node.py +2 -2
  11. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/evaluate_node.py +2 -2
  12. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/human_input_node.py +6 -0
  13. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/questioner_node.py +13 -4
  14. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/solution_node.py +13 -4
  15. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/runner.py +11 -0
  16. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/state/state.py +4 -1
  17. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/cli.py +1 -1
  18. socratic_debug-0.0.6/src/db/connection.py +64 -0
  19. socratic_debug-0.0.6/src/db/detector.py +49 -0
  20. socratic_debug-0.0.6/src/db/migrator.py +56 -0
  21. socratic_debug-0.0.6/src/db/models.py +27 -0
  22. socratic_debug-0.0.6/src/db/service.py +76 -0
  23. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/events.py +29 -0
  24. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/hook.py +1 -1
  25. {socratic_debug-0.0.4/src → socratic_debug-0.0.6/src/utils}/config_creator.py +2 -2
  26. socratic_debug-0.0.6/src/utils/config_manager.py +45 -0
  27. {socratic_debug-0.0.4/src → socratic_debug-0.0.6/src/utils}/config_template.py +4 -0
  28. socratic_debug-0.0.6/src/utils/config_watcher.py +22 -0
  29. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/utils/read_yaml.py +1 -1
  30. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/watcher.py +12 -0
  31. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/adapter.py +1 -0
  32. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/app.py +148 -2
  33. socratic_debug-0.0.6/ui/settings_drawer.py +306 -0
  34. socratic_debug-0.0.6/ui/styles.py +147 -0
  35. socratic_debug-0.0.6/ui/translations.py +85 -0
  36. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/views.py +12 -0
  37. socratic_debug-0.0.4/README.md +0 -126
  38. socratic_debug-0.0.4/ui/styles.py +0 -63
  39. socratic_debug-0.0.4/ui/translations.py +0 -37
  40. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/LICENSE +0 -0
  41. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/setup.cfg +0 -0
  42. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic.py +0 -0
  43. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/dependency_links.txt +0 -0
  44. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/entry_points.txt +0 -0
  45. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/top_level.txt +0 -0
  46. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/__init__.py +0 -0
  47. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/graph/graph.py +0 -0
  48. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/__init__.py +0 -0
  49. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/openrouter.py +0 -0
  50. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/diagnose_prompt.py +0 -0
  51. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/evaluation_prompt.py +0 -0
  52. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/mentor_prompt.py +0 -0
  53. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/questioner_prompt.py +0 -0
  54. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/solution_prompt.py +0 -0
  55. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/extractor.py +0 -0
  56. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/test/test_hook.py +0 -0
  57. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/__init__.py +0 -0
  58. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/bidi.py +0 -0
  59. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/console.py +0 -0
  60. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/templates.py +0 -0
  61. {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/window.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socratic-debug
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith
5
5
  Author: Mohamed Elawakey
6
6
  Requires-Python: >=3.10
@@ -13,38 +13,61 @@ Requires-Dist: langgraph>=1.2.0
13
13
  Requires-Dist: langchain>=1.4.0
14
14
  Requires-Dist: langchain-ollama>=1.1.0
15
15
  Requires-Dist: langchain-openrouter>=0.2.0
16
+ Requires-Dist: sqlalchemy>=2.0.0
16
17
  Dynamic: license-file
17
18
 
18
19
  # 🧠 Socratic Debug (`socratic`)
19
20
 
20
21
  > **Stop copying stack traces. Start mastering your bugs.**
21
- > An autonomous pedagogical debugger and mentor powered by LangGraph, PyQt6, and LangSmith.
22
+ > An autonomous pedagogical debugger and AI mentor built for **students learning to code** and **developers** who want to truly understand their errors instead of copy-pasting AI patches.
22
23
 
23
24
  [![CI](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml/badge.svg)](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
24
25
  [![PyPI version](https://img.shields.io/pypi/v/socratic-debug.svg?color=blue)](https://pypi.org/project/socratic-debug/)
25
- [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
26
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
26
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org/)
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
28
+ [![LangChain](https://img.shields.io/badge/LangChain-1.4+-1C3C3C?logo=chainlink&logoColor=white)](https://www.langchain.com/)
29
+ [![LangGraph](https://img.shields.io/badge/LangGraph-1.2+-FF8800?logo=diagram-next&logoColor=white)](https://langchain-ai.github.io/langgraph/)
30
+ [![PyQt6](https://img.shields.io/badge/PyQt6-GUI%20Terminal-41CD52?logo=qt&logoColor=white)](https://riverbankcomputing.com/software/pyqt/)
31
+ [![Rich](https://img.shields.io/badge/Rich-Terminal%20UX-blueviolet)](https://github.com/Textualize/rich)
32
+
33
+ [📦 PyPI Package](https://pypi.org/project/socratic-debug/) • [🐛 Report Bug](https://github.com/mohamedelawakey/socratic/issues)
34
+
35
+ ---
36
+
37
+ <p align="center">
38
+ <a href="test/test_hook.py">
39
+ <img src="assets/socratic_ui_demo.png" alt="Socratic Debug Interactive Desktop UI" width="900" style="border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.5);" />
40
+ </a>
41
+ <br />
42
+ <sub>⚡ <em>Interactive debugging session generated live from <a href="test/test_hook.py"><code>test/test_hook.py</code></a></em></sub>
43
+ </p>
27
44
 
28
45
  ---
29
46
 
30
47
  ## 💡 Why Socratic?
31
48
 
32
- When a runtime crash happens, most developers find themselves trapped in one of two extremes:
33
- 1. **The Intimidating Traceback:** Staring at a terrifying wall of 50-line red terminal text, unsure which line actually caused the root flaw.
34
- 2. **The "Copier" Reflex:** Blindly copying the error into an LLM chat, pasting the patch without understanding *why* it failed, only to trigger the exact same design mistake minutes later.
49
+ When a runtime crash happens, both beginners learning to program and seasoned developers often hit a wall:
50
+ 1. **For Students & Beginners:** A 50-line red terminal traceback feels overwhelming and cryptic. In the age of AI, copying the error into an LLM and pasting the generated code creates an illusion of progress—the student passes the assignment but never builds problem-solving intuition or mental models.
51
+ 2. **For Developers & Engineers:** Blindly pasting fixes without dissecting the failure mechanism leads to fragile code, cascading bugs, and recurring design flaws.
35
52
 
36
- **Socratic Debug changes the game.**
37
- Instead of dumping stack traces or spoon-feeding copy-paste patches, `socratic` intercepts uncaught runtime crashes and launches a **dedicated desktop mentorship window**. It analyzes the bug silently and guides you through a calibrated, interactive dialogue to help you **discover, understand, and fix the root cause yourself.**
53
+ **Socratic Debug changes the paradigm.**
54
+ Instead of dumping walls of red text or spoon-feeding copy-paste solutions, `socratic` intercepts uncaught runtime crashes and launches a **dedicated desktop mentorship window**. Powered by LangGraph, it acts like a personal coding instructor sitting right next to you:
55
+ - It guides you through a progressive, calibrated Socratic dialogue.
56
+ - It asks probing questions that help you spot the exact misconception on your own.
57
+ - It verifies your understanding before finally unlocking defensive programming best practices.
38
58
 
39
59
  ---
40
60
 
41
61
  ## ✨ Features
42
62
 
43
- - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal pollution.
63
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal clutter.
64
+ - ⚙️ **In-App Settings Drawer & Secret Masking:** Configure models and API keys directly from the GUI with a slide-in settings panel, toggleable secret masking (`👁️`), and instant hot-reloading.
65
+ - ⚡ **Real-Time Auto-Reload & Live Watcher:** Background file monitor (`FileMonitor`) listens for fixes as you edit your code. It handles editor auto-save with a smart typing debounce, validates syntax, and auto-detects solutions live—no manual re-runs needed!
44
66
  - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
45
67
  - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
46
68
  - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
47
69
  - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
70
+ - 🏗️ **Clean Decoupled Architecture:** Core agent nodes and exception hooks communicate via an abstract `EventBus`, allowing Socratic to plug cleanly into Desktop GUI, CLI, or future IDE plugins (VS Code, JetBrains).
48
71
  - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
49
72
  - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
50
73
 
@@ -87,6 +110,7 @@ socratic run my_script.py
87
110
  ```
88
111
  - If your script runs successfully, it outputs normally.
89
112
  - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
113
+ - Edit your file in your editor (VS Code, PyCharm, etc.)—Socratic will detect your fix live and celebrate your solution!
90
114
 
91
115
  ### Method 2: In-Process Runtime Hook
92
116
  If you are building an application or library and want Socratic guidance baked directly into development runs:
@@ -105,7 +129,7 @@ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
105
129
 
106
130
  ## ⚙️ Configuration (`.socratic.yaml`)
107
131
 
108
- When you run `socratic` for the first time, it automatically creates a `.socratic.yaml` config file in your project or home directory:
132
+ You can configure settings via the in-app **⚙️ Settings** drawer or directly in `.socratic.yaml`:
109
133
 
110
134
  ```yaml
111
135
  # LLM Provider: "ollama" or "openrouter"
@@ -117,7 +141,7 @@ provider_link: "http://localhost:11434"
117
141
  api_key: "your_api_key_here"
118
142
 
119
143
  # Mentor Personality & Language ("Arabic" or "English")
120
- socratic_language: "Arabic"
144
+ socratic_language: "English"
121
145
  socratic_style: "friendly"
122
146
 
123
147
  # Observability with LangSmith (Optional)
@@ -129,10 +153,11 @@ LANGSMITH_PROJECT: "socratic-debug"
129
153
  ---
130
154
 
131
155
  ## 🤝 Contributing
132
-
133
- We welcome contributions! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
134
- - For large architectural changes or new features, **please open a GitHub Discussion first**.
135
- - For minor bug fixes, direct Pull Requests are warmly welcome.
156
+
157
+ We welcome contributions from developers worldwide! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
158
+ - For feature requests or major changes, **please open a GitHub Discussion or Issue first**.
159
+ - For bug fixes, direct Pull Requests are warmly welcome.
160
+ - Browse our open issues labeled `good first issue` to start contributing.
136
161
 
137
162
  Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
138
163
 
@@ -0,0 +1,150 @@
1
+ # 🧠 Socratic Debug (`socratic`)
2
+
3
+ > **Stop copying stack traces. Start mastering your bugs.**
4
+ > An autonomous pedagogical debugger and AI mentor built for **students learning to code** and **developers** who want to truly understand their errors instead of copy-pasting AI patches.
5
+
6
+ [![CI](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml/badge.svg)](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
7
+ [![PyPI version](https://img.shields.io/pypi/v/socratic-debug.svg?color=blue)](https://pypi.org/project/socratic-debug/)
8
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
10
+ [![LangChain](https://img.shields.io/badge/LangChain-1.4+-1C3C3C?logo=chainlink&logoColor=white)](https://www.langchain.com/)
11
+ [![LangGraph](https://img.shields.io/badge/LangGraph-1.2+-FF8800?logo=diagram-next&logoColor=white)](https://langchain-ai.github.io/langgraph/)
12
+ [![PyQt6](https://img.shields.io/badge/PyQt6-GUI%20Terminal-41CD52?logo=qt&logoColor=white)](https://riverbankcomputing.com/software/pyqt/)
13
+ [![Rich](https://img.shields.io/badge/Rich-Terminal%20UX-blueviolet)](https://github.com/Textualize/rich)
14
+
15
+ [📦 PyPI Package](https://pypi.org/project/socratic-debug/) • [🐛 Report Bug](https://github.com/mohamedelawakey/socratic/issues)
16
+
17
+ ---
18
+
19
+ <p align="center">
20
+ <a href="test/test_hook.py">
21
+ <img src="assets/socratic_ui_demo.png" alt="Socratic Debug Interactive Desktop UI" width="900" style="border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.5);" />
22
+ </a>
23
+ <br />
24
+ <sub>⚡ <em>Interactive debugging session generated live from <a href="test/test_hook.py"><code>test/test_hook.py</code></a></em></sub>
25
+ </p>
26
+
27
+ ---
28
+
29
+ ## 💡 Why Socratic?
30
+
31
+ When a runtime crash happens, both beginners learning to program and seasoned developers often hit a wall:
32
+ 1. **For Students & Beginners:** A 50-line red terminal traceback feels overwhelming and cryptic. In the age of AI, copying the error into an LLM and pasting the generated code creates an illusion of progress—the student passes the assignment but never builds problem-solving intuition or mental models.
33
+ 2. **For Developers & Engineers:** Blindly pasting fixes without dissecting the failure mechanism leads to fragile code, cascading bugs, and recurring design flaws.
34
+
35
+ **Socratic Debug changes the paradigm.**
36
+ Instead of dumping walls of red text or spoon-feeding copy-paste solutions, `socratic` intercepts uncaught runtime crashes and launches a **dedicated desktop mentorship window**. Powered by LangGraph, it acts like a personal coding instructor sitting right next to you:
37
+ - It guides you through a progressive, calibrated Socratic dialogue.
38
+ - It asks probing questions that help you spot the exact misconception on your own.
39
+ - It verifies your understanding before finally unlocking defensive programming best practices.
40
+
41
+ ---
42
+
43
+ ## ✨ Features
44
+
45
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal clutter.
46
+ - ⚙️ **In-App Settings Drawer & Secret Masking:** Configure models and API keys directly from the GUI with a slide-in settings panel, toggleable secret masking (`👁️`), and instant hot-reloading.
47
+ - ⚡ **Real-Time Auto-Reload & Live Watcher:** Background file monitor (`FileMonitor`) listens for fixes as you edit your code. It handles editor auto-save with a smart typing debounce, validates syntax, and auto-detects solutions live—no manual re-runs needed!
48
+ - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
49
+ - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
50
+ - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
51
+ - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
52
+ - 🏗️ **Clean Decoupled Architecture:** Core agent nodes and exception hooks communicate via an abstract `EventBus`, allowing Socratic to plug cleanly into Desktop GUI, CLI, or future IDE plugins (VS Code, JetBrains).
53
+ - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
54
+ - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
55
+
56
+ ---
57
+
58
+ ## 🚀 Quick Start
59
+
60
+ ### Installation
61
+
62
+ The cleanest, recommended way to install `socratic` globally across your system without virtual environment conflicts:
63
+
64
+ ```bash
65
+ # Recommended (isolated global CLI)
66
+ pipx install socratic-debug
67
+
68
+ # Or via standard pip
69
+ pip install socratic-debug
70
+ ```
71
+
72
+ Alternatively, use the one-line install script:
73
+ ```bash
74
+ # Linux & macOS
75
+ curl -sSL https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.sh | bash
76
+
77
+ # Windows (PowerShell)
78
+ irm https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.ps1 | iex
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🛠️ Usage
84
+
85
+ You can use `socratic` in two distinct ways:
86
+
87
+ ### Method 1: Zero-Code-Change CLI Runner (Recommended)
88
+ You don't need to add any code or imports to your script! Simply prefix your execution:
89
+
90
+ ```bash
91
+ socratic run my_script.py
92
+ ```
93
+ - If your script runs successfully, it outputs normally.
94
+ - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
95
+ - Edit your file in your editor (VS Code, PyCharm, etc.)—Socratic will detect your fix live and celebrate your solution!
96
+
97
+ ### Method 2: In-Process Runtime Hook
98
+ If you are building an application or library and want Socratic guidance baked directly into development runs:
99
+
100
+ ```python
101
+ import socratic
102
+ socratic.install()
103
+
104
+ # Your regular application code
105
+ number_1 = 10
106
+ number_2 = 0
107
+ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
108
+ ```
109
+
110
+ ---
111
+
112
+ ## ⚙️ Configuration (`.socratic.yaml`)
113
+
114
+ You can configure settings via the in-app **⚙️ Settings** drawer or directly in `.socratic.yaml`:
115
+
116
+ ```yaml
117
+ # LLM Provider: "ollama" or "openrouter"
118
+ provider: "ollama"
119
+ provider_name: "gemma4:31b-cloud"
120
+ provider_link: "http://localhost:11434"
121
+
122
+ # API Key (for cloud providers like OpenRouter)
123
+ api_key: "your_api_key_here"
124
+
125
+ # Mentor Personality & Language ("Arabic" or "English")
126
+ socratic_language: "English"
127
+ socratic_style: "friendly"
128
+
129
+ # Observability with LangSmith (Optional)
130
+ LANGSMITH_TRACING: "true"
131
+ LANGSMITH_API_KEY: "lsv2_pt_..."
132
+ LANGSMITH_PROJECT: "socratic-debug"
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 🤝 Contributing
138
+
139
+ We welcome contributions from developers worldwide! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
140
+ - For feature requests or major changes, **please open a GitHub Discussion or Issue first**.
141
+ - For bug fixes, direct Pull Requests are warmly welcome.
142
+ - Browse our open issues labeled `good first issue` to start contributing.
143
+
144
+ Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
145
+
146
+ ---
147
+
148
+ ## 📄 License
149
+
150
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "socratic-debug"
7
- version = "0.0.4"
7
+ version = "0.0.6"
8
8
  description = "Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith"
9
9
  authors = [{ name = "Mohamed Elawakey" }]
10
10
  readme = "README.md"
@@ -17,6 +17,7 @@ dependencies = [
17
17
  "langchain>=1.4.0",
18
18
  "langchain-ollama>=1.1.0",
19
19
  "langchain-openrouter>=0.2.0",
20
+ "sqlalchemy>=2.0.0",
20
21
  ]
21
22
 
22
23
  [project.scripts]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socratic-debug
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith
5
5
  Author: Mohamed Elawakey
6
6
  Requires-Python: >=3.10
@@ -13,38 +13,61 @@ Requires-Dist: langgraph>=1.2.0
13
13
  Requires-Dist: langchain>=1.4.0
14
14
  Requires-Dist: langchain-ollama>=1.1.0
15
15
  Requires-Dist: langchain-openrouter>=0.2.0
16
+ Requires-Dist: sqlalchemy>=2.0.0
16
17
  Dynamic: license-file
17
18
 
18
19
  # 🧠 Socratic Debug (`socratic`)
19
20
 
20
21
  > **Stop copying stack traces. Start mastering your bugs.**
21
- > An autonomous pedagogical debugger and mentor powered by LangGraph, PyQt6, and LangSmith.
22
+ > An autonomous pedagogical debugger and AI mentor built for **students learning to code** and **developers** who want to truly understand their errors instead of copy-pasting AI patches.
22
23
 
23
24
  [![CI](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml/badge.svg)](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
24
25
  [![PyPI version](https://img.shields.io/pypi/v/socratic-debug.svg?color=blue)](https://pypi.org/project/socratic-debug/)
25
- [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
26
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
26
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org/)
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
28
+ [![LangChain](https://img.shields.io/badge/LangChain-1.4+-1C3C3C?logo=chainlink&logoColor=white)](https://www.langchain.com/)
29
+ [![LangGraph](https://img.shields.io/badge/LangGraph-1.2+-FF8800?logo=diagram-next&logoColor=white)](https://langchain-ai.github.io/langgraph/)
30
+ [![PyQt6](https://img.shields.io/badge/PyQt6-GUI%20Terminal-41CD52?logo=qt&logoColor=white)](https://riverbankcomputing.com/software/pyqt/)
31
+ [![Rich](https://img.shields.io/badge/Rich-Terminal%20UX-blueviolet)](https://github.com/Textualize/rich)
32
+
33
+ [📦 PyPI Package](https://pypi.org/project/socratic-debug/) • [🐛 Report Bug](https://github.com/mohamedelawakey/socratic/issues)
34
+
35
+ ---
36
+
37
+ <p align="center">
38
+ <a href="test/test_hook.py">
39
+ <img src="assets/socratic_ui_demo.png" alt="Socratic Debug Interactive Desktop UI" width="900" style="border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.5);" />
40
+ </a>
41
+ <br />
42
+ <sub>⚡ <em>Interactive debugging session generated live from <a href="test/test_hook.py"><code>test/test_hook.py</code></a></em></sub>
43
+ </p>
27
44
 
28
45
  ---
29
46
 
30
47
  ## 💡 Why Socratic?
31
48
 
32
- When a runtime crash happens, most developers find themselves trapped in one of two extremes:
33
- 1. **The Intimidating Traceback:** Staring at a terrifying wall of 50-line red terminal text, unsure which line actually caused the root flaw.
34
- 2. **The "Copier" Reflex:** Blindly copying the error into an LLM chat, pasting the patch without understanding *why* it failed, only to trigger the exact same design mistake minutes later.
49
+ When a runtime crash happens, both beginners learning to program and seasoned developers often hit a wall:
50
+ 1. **For Students & Beginners:** A 50-line red terminal traceback feels overwhelming and cryptic. In the age of AI, copying the error into an LLM and pasting the generated code creates an illusion of progress—the student passes the assignment but never builds problem-solving intuition or mental models.
51
+ 2. **For Developers & Engineers:** Blindly pasting fixes without dissecting the failure mechanism leads to fragile code, cascading bugs, and recurring design flaws.
35
52
 
36
- **Socratic Debug changes the game.**
37
- Instead of dumping stack traces or spoon-feeding copy-paste patches, `socratic` intercepts uncaught runtime crashes and launches a **dedicated desktop mentorship window**. It analyzes the bug silently and guides you through a calibrated, interactive dialogue to help you **discover, understand, and fix the root cause yourself.**
53
+ **Socratic Debug changes the paradigm.**
54
+ Instead of dumping walls of red text or spoon-feeding copy-paste solutions, `socratic` intercepts uncaught runtime crashes and launches a **dedicated desktop mentorship window**. Powered by LangGraph, it acts like a personal coding instructor sitting right next to you:
55
+ - It guides you through a progressive, calibrated Socratic dialogue.
56
+ - It asks probing questions that help you spot the exact misconception on your own.
57
+ - It verifies your understanding before finally unlocking defensive programming best practices.
38
58
 
39
59
  ---
40
60
 
41
61
  ## ✨ Features
42
62
 
43
- - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal pollution.
63
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal clutter.
64
+ - ⚙️ **In-App Settings Drawer & Secret Masking:** Configure models and API keys directly from the GUI with a slide-in settings panel, toggleable secret masking (`👁️`), and instant hot-reloading.
65
+ - ⚡ **Real-Time Auto-Reload & Live Watcher:** Background file monitor (`FileMonitor`) listens for fixes as you edit your code. It handles editor auto-save with a smart typing debounce, validates syntax, and auto-detects solutions live—no manual re-runs needed!
44
66
  - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
45
67
  - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
46
68
  - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
47
69
  - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
70
+ - 🏗️ **Clean Decoupled Architecture:** Core agent nodes and exception hooks communicate via an abstract `EventBus`, allowing Socratic to plug cleanly into Desktop GUI, CLI, or future IDE plugins (VS Code, JetBrains).
48
71
  - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
49
72
  - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
50
73
 
@@ -87,6 +110,7 @@ socratic run my_script.py
87
110
  ```
88
111
  - If your script runs successfully, it outputs normally.
89
112
  - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
113
+ - Edit your file in your editor (VS Code, PyCharm, etc.)—Socratic will detect your fix live and celebrate your solution!
90
114
 
91
115
  ### Method 2: In-Process Runtime Hook
92
116
  If you are building an application or library and want Socratic guidance baked directly into development runs:
@@ -105,7 +129,7 @@ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
105
129
 
106
130
  ## ⚙️ Configuration (`.socratic.yaml`)
107
131
 
108
- When you run `socratic` for the first time, it automatically creates a `.socratic.yaml` config file in your project or home directory:
132
+ You can configure settings via the in-app **⚙️ Settings** drawer or directly in `.socratic.yaml`:
109
133
 
110
134
  ```yaml
111
135
  # LLM Provider: "ollama" or "openrouter"
@@ -117,7 +141,7 @@ provider_link: "http://localhost:11434"
117
141
  api_key: "your_api_key_here"
118
142
 
119
143
  # Mentor Personality & Language ("Arabic" or "English")
120
- socratic_language: "Arabic"
144
+ socratic_language: "English"
121
145
  socratic_style: "friendly"
122
146
 
123
147
  # Observability with LangSmith (Optional)
@@ -129,10 +153,11 @@ LANGSMITH_PROJECT: "socratic-debug"
129
153
  ---
130
154
 
131
155
  ## 🤝 Contributing
132
-
133
- We welcome contributions! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
134
- - For large architectural changes or new features, **please open a GitHub Discussion first**.
135
- - For minor bug fixes, direct Pull Requests are warmly welcome.
156
+
157
+ We welcome contributions from developers worldwide! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
158
+ - For feature requests or major changes, **please open a GitHub Discussion or Issue first**.
159
+ - For bug fixes, direct Pull Requests are warmly welcome.
160
+ - Browse our open issues labeled `good first issue` to start contributing.
136
161
 
137
162
  Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
138
163
 
@@ -10,8 +10,6 @@ socratic_debug.egg-info/requires.txt
10
10
  socratic_debug.egg-info/top_level.txt
11
11
  src/__init__.py
12
12
  src/cli.py
13
- src/config_creator.py
14
- src/config_template.py
15
13
  src/events.py
16
14
  src/extractor.py
17
15
  src/hook.py
@@ -19,6 +17,7 @@ src/watcher.py
19
17
  src/agent/runner.py
20
18
  src/agent/graph/graph.py
21
19
  src/agent/llm/factory.py
20
+ src/agent/llm/invoker.py
22
21
  src/agent/llm/providers/__init__.py
23
22
  src/agent/llm/providers/ollama.py
24
23
  src/agent/llm/providers/openrouter.py
@@ -33,6 +32,15 @@ src/agent/prompts/mentor_prompt.py
33
32
  src/agent/prompts/questioner_prompt.py
34
33
  src/agent/prompts/solution_prompt.py
35
34
  src/agent/state/state.py
35
+ src/db/connection.py
36
+ src/db/detector.py
37
+ src/db/migrator.py
38
+ src/db/models.py
39
+ src/db/service.py
40
+ src/utils/config_creator.py
41
+ src/utils/config_manager.py
42
+ src/utils/config_template.py
43
+ src/utils/config_watcher.py
36
44
  src/utils/read_yaml.py
37
45
  test/test_hook.py
38
46
  ui/__init__.py
@@ -40,6 +48,7 @@ ui/adapter.py
40
48
  ui/app.py
41
49
  ui/bidi.py
42
50
  ui/console.py
51
+ ui/settings_drawer.py
43
52
  ui/styles.py
44
53
  ui/templates.py
45
54
  ui/translations.py
@@ -5,3 +5,4 @@ langgraph>=1.2.0
5
5
  langchain>=1.4.0
6
6
  langchain-ollama>=1.1.0
7
7
  langchain-openrouter>=0.2.0
8
+ sqlalchemy>=2.0.0
@@ -1,4 +1,5 @@
1
- from src.agent.llm.providers import *
1
+ from src.agent.llm.providers.openrouter import OpenRouterLLM
2
+ from src.agent.llm.providers.ollama import OllamaLLM
2
3
  from src.utils.read_yaml import ReadYaml
3
4
 
4
5
 
@@ -0,0 +1,28 @@
1
+ import os
2
+ import time
3
+ from src.agent.llm.factory import LLMFactory
4
+ from src.events import EventBus
5
+
6
+
7
+ class LLMInvoker:
8
+ @staticmethod
9
+ def invoke_with_retry(prompt: str, max_headless_retries: int = 3):
10
+ is_gui = os.environ.get("SOCRATIC_GUI_ACTIVE") == "1"
11
+ attempts = 0
12
+
13
+ while True:
14
+ if EventBus.is_session_cancelled():
15
+ raise RuntimeError("Session was cancelled by user.")
16
+
17
+ try:
18
+ return LLMFactory.get_llm().invoke(prompt)
19
+ except Exception as e:
20
+ err_msg = str(e)
21
+ EventBus.emit_llm_error(err_msg)
22
+
23
+ if not is_gui:
24
+ attempts += 1
25
+ if attempts >= max_headless_retries:
26
+ raise RuntimeError(f"LLM invocation failed after {attempts} attempts: {err_msg}") from e
27
+
28
+ time.sleep(2)
@@ -7,7 +7,7 @@ class OllamaLLM:
7
7
  def ollama_llm():
8
8
  config = ReadYaml.read_yaml()
9
9
 
10
- return ChatOllama (
10
+ return ChatOllama(
11
11
  model=config["provider_name"],
12
12
  base_url=config["provider_link"],
13
13
  )
@@ -1,6 +1,6 @@
1
1
  from src.agent.prompts.diagnose_prompt import DiagnosePrompt
2
2
  from src.agent.state.state import SocraticAgentState
3
- from src.agent.llm.factory import LLMFactory
3
+ from src.agent.llm.invoker import LLMInvoker
4
4
 
5
5
 
6
6
  class DiagnoseNode:
@@ -16,6 +16,6 @@ class DiagnoseNode:
16
16
  function_name=state.get("function_name") or "",
17
17
  )
18
18
 
19
- response = LLMFactory.get_llm().invoke(prompt)
19
+ response = LLMInvoker.invoke_with_retry(prompt)
20
20
 
21
21
  return {"root_cause": response.content}
@@ -1,6 +1,6 @@
1
1
  from src.agent.prompts.evaluation_prompt import EvaluationPrompt
2
2
  from src.agent.state.state import SocraticAgentState
3
- from src.agent.llm.factory import LLMFactory
3
+ from src.agent.llm.invoker import LLMInvoker
4
4
  from src.events import EventBus
5
5
 
6
6
 
@@ -26,7 +26,7 @@ class EvaluationNode:
26
26
  user_input=user_input,
27
27
  )
28
28
 
29
- response = LLMFactory.get_llm().invoke(prompt)
29
+ response = LLMInvoker.invoke_with_retry(prompt)
30
30
  verdict = response.content.strip().upper()
31
31
 
32
32
  if "SOLVED" in verdict and "UNSOLVED" not in verdict and "NOT SOLVED" not in verdict:
@@ -7,6 +7,12 @@ class HumanInputNode:
7
7
  def human_input_node(state: SocraticAgentState) -> dict:
8
8
  user_input = EventBus.request_user_input()
9
9
 
10
+ # Increment dialogue turns count in database
11
+ event_id = state.get("event_id")
12
+ if event_id:
13
+ from src.db.service import MetricsService
14
+ MetricsService.increment_dialogue_turns(event_id)
15
+
10
16
  history = list(state.get("dialogue_history", []))
11
17
  history.append({"role": "student", "content": user_input})
12
18
 
@@ -1,6 +1,6 @@
1
1
  from src.agent.prompts.questioner_prompt import QuestionerPrompt
2
2
  from src.agent.state.state import SocraticAgentState
3
- from src.agent.llm.factory import LLMFactory
3
+ from src.agent.llm.invoker import LLMInvoker
4
4
  from src.utils.read_yaml import ReadYaml
5
5
 
6
6
  from src.events import EventBus
@@ -14,6 +14,9 @@ class QuestionerNode:
14
14
  current_hint = state.get("hint_level", 1)
15
15
  raw_history = state.get("dialogue_history", [])
16
16
 
17
+ # Re-read YAML configuration dynamically to reflect any runtime updates
18
+ live_config = ReadYaml.read_yaml()
19
+
17
20
  formatted_history = "\n".join(
18
21
  f"- {turn.get('role', 'unknown').capitalize()}: {turn.get('content', '')}"
19
22
  for turn in raw_history
@@ -27,11 +30,17 @@ class QuestionerNode:
27
30
  root_cause=state["root_cause"],
28
31
  dialogue_history=formatted_history,
29
32
  hint_level=current_hint,
30
- language=config.get("socratic_language", "English"),
31
- style=config.get("socratic_style", "friendly"),
33
+ language=live_config.get("socratic_language", "English"),
34
+ style=live_config.get("socratic_style", "friendly"),
32
35
  )
33
36
 
34
- response = LLMFactory.get_llm().invoke(prompt)
37
+ response = LLMInvoker.invoke_with_retry(prompt)
38
+
39
+ # Update hint level metric in database
40
+ event_id = state.get("event_id")
41
+ if event_id:
42
+ from src.db.service import MetricsService
43
+ MetricsService.update_hint_level(event_id, current_hint)
35
44
 
36
45
  EventBus.emit_mentor_message(
37
46
  content=response.content,
@@ -1,6 +1,6 @@
1
1
  from src.agent.prompts.solution_prompt import SolutionPrompt
2
2
  from src.agent.state.state import SocraticAgentState
3
- from src.agent.llm.factory import LLMFactory
3
+ from src.agent.llm.invoker import LLMInvoker
4
4
  from src.utils.read_yaml import ReadYaml
5
5
  from src.events import EventBus
6
6
 
@@ -12,17 +12,26 @@ class SolutionNode:
12
12
  def solution_node(state: SocraticAgentState) -> dict:
13
13
  current_status = state.get("eval_status", "solved")
14
14
 
15
+ # Dynamically re-read config to adapt to live changes
16
+ live_config = ReadYaml.read_yaml()
17
+
15
18
  prompt = SolutionPrompt.solution_prompt(
16
19
  error_type=state["error_type"],
17
20
  line_number=state["line_number"],
18
21
  code_snippet=state["code_snippet"],
19
22
  root_cause=state["root_cause"],
20
23
  eval_status=current_status,
21
- language=config.get("socratic_language", "English"),
22
- style=config.get("socratic_style", "friendly"),
24
+ language=live_config.get("socratic_language", "English"),
25
+ style=live_config.get("socratic_style", "friendly"),
23
26
  )
24
27
 
25
- response = LLMFactory.get_llm().invoke(prompt)
28
+ response = LLMInvoker.invoke_with_retry(prompt)
29
+
30
+ # Mark error event as resolved in database
31
+ event_id = state.get("event_id")
32
+ if event_id:
33
+ from src.db.service import MetricsService
34
+ MetricsService.record_error_resolved(event_id)
26
35
 
27
36
  EventBus.emit_solution(response.content)
28
37