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.
- {socratic_debug-0.0.4/socratic_debug.egg-info → socratic_debug-0.0.6}/PKG-INFO +41 -16
- socratic_debug-0.0.6/README.md +150 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/pyproject.toml +2 -1
- {socratic_debug-0.0.4 → socratic_debug-0.0.6/socratic_debug.egg-info}/PKG-INFO +41 -16
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/SOURCES.txt +11 -2
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/requires.txt +1 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/factory.py +2 -1
- socratic_debug-0.0.6/src/agent/llm/invoker.py +28 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/ollama.py +1 -1
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/diagnose_node.py +2 -2
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/evaluate_node.py +2 -2
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/human_input_node.py +6 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/questioner_node.py +13 -4
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/nodes/solution_node.py +13 -4
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/runner.py +11 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/state/state.py +4 -1
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/cli.py +1 -1
- socratic_debug-0.0.6/src/db/connection.py +64 -0
- socratic_debug-0.0.6/src/db/detector.py +49 -0
- socratic_debug-0.0.6/src/db/migrator.py +56 -0
- socratic_debug-0.0.6/src/db/models.py +27 -0
- socratic_debug-0.0.6/src/db/service.py +76 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/events.py +29 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/hook.py +1 -1
- {socratic_debug-0.0.4/src → socratic_debug-0.0.6/src/utils}/config_creator.py +2 -2
- socratic_debug-0.0.6/src/utils/config_manager.py +45 -0
- {socratic_debug-0.0.4/src → socratic_debug-0.0.6/src/utils}/config_template.py +4 -0
- socratic_debug-0.0.6/src/utils/config_watcher.py +22 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/utils/read_yaml.py +1 -1
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/watcher.py +12 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/adapter.py +1 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/app.py +148 -2
- socratic_debug-0.0.6/ui/settings_drawer.py +306 -0
- socratic_debug-0.0.6/ui/styles.py +147 -0
- socratic_debug-0.0.6/ui/translations.py +85 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/views.py +12 -0
- socratic_debug-0.0.4/README.md +0 -126
- socratic_debug-0.0.4/ui/styles.py +0 -63
- socratic_debug-0.0.4/ui/translations.py +0 -37
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/LICENSE +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/setup.cfg +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/dependency_links.txt +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/entry_points.txt +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/socratic_debug.egg-info/top_level.txt +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/__init__.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/graph/graph.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/__init__.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/llm/providers/openrouter.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/diagnose_prompt.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/evaluation_prompt.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/mentor_prompt.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/questioner_prompt.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/agent/prompts/solution_prompt.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/src/extractor.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/test/test_hook.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/__init__.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/bidi.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/console.py +0 -0
- {socratic_debug-0.0.4 → socratic_debug-0.0.6}/ui/templates.py +0 -0
- {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.
|
|
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
|
|
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
|
[](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
|
|
24
25
|
[](https://pypi.org/project/socratic-debug/)
|
|
25
|
-
[](https://www.python.org/)
|
|
26
|
-
[](LICENSE)
|
|
26
|
+
[](https://www.python.org/)
|
|
27
|
+
[](LICENSE)
|
|
28
|
+
[](https://www.langchain.com/)
|
|
29
|
+
[](https://langchain-ai.github.io/langgraph/)
|
|
30
|
+
[](https://riverbankcomputing.com/software/pyqt/)
|
|
31
|
+
[](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,
|
|
33
|
-
1. **
|
|
34
|
-
2. **
|
|
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
|
|
37
|
-
Instead of dumping
|
|
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
|
|
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
|
-
|
|
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: "
|
|
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
|
|
135
|
-
- For
|
|
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
|
+
[](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
|
|
7
|
+
[](https://pypi.org/project/socratic-debug/)
|
|
8
|
+
[](https://www.python.org/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://www.langchain.com/)
|
|
11
|
+
[](https://langchain-ai.github.io/langgraph/)
|
|
12
|
+
[](https://riverbankcomputing.com/software/pyqt/)
|
|
13
|
+
[](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.
|
|
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.
|
|
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
|
|
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
|
[](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
|
|
24
25
|
[](https://pypi.org/project/socratic-debug/)
|
|
25
|
-
[](https://www.python.org/)
|
|
26
|
-
[](LICENSE)
|
|
26
|
+
[](https://www.python.org/)
|
|
27
|
+
[](LICENSE)
|
|
28
|
+
[](https://www.langchain.com/)
|
|
29
|
+
[](https://langchain-ai.github.io/langgraph/)
|
|
30
|
+
[](https://riverbankcomputing.com/software/pyqt/)
|
|
31
|
+
[](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,
|
|
33
|
-
1. **
|
|
34
|
-
2. **
|
|
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
|
|
37
|
-
Instead of dumping
|
|
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
|
|
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
|
-
|
|
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: "
|
|
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
|
|
135
|
-
- For
|
|
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
|
|
@@ -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)
|
|
@@ -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.
|
|
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 =
|
|
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.
|
|
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 =
|
|
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.
|
|
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=
|
|
31
|
-
style=
|
|
33
|
+
language=live_config.get("socratic_language", "English"),
|
|
34
|
+
style=live_config.get("socratic_style", "friendly"),
|
|
32
35
|
)
|
|
33
36
|
|
|
34
|
-
response =
|
|
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.
|
|
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=
|
|
22
|
-
style=
|
|
24
|
+
language=live_config.get("socratic_language", "English"),
|
|
25
|
+
style=live_config.get("socratic_style", "friendly"),
|
|
23
26
|
)
|
|
24
27
|
|
|
25
|
-
response =
|
|
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
|
|