socratic-debug 0.0.1__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 (46) hide show
  1. socratic_debug-0.0.1/LICENSE +21 -0
  2. socratic_debug-0.0.1/PKG-INFO +143 -0
  3. socratic_debug-0.0.1/README.md +126 -0
  4. socratic_debug-0.0.1/pyproject.toml +30 -0
  5. socratic_debug-0.0.1/setup.cfg +4 -0
  6. socratic_debug-0.0.1/socratic.py +8 -0
  7. socratic_debug-0.0.1/socratic_debug.egg-info/PKG-INFO +143 -0
  8. socratic_debug-0.0.1/socratic_debug.egg-info/SOURCES.txt +44 -0
  9. socratic_debug-0.0.1/socratic_debug.egg-info/dependency_links.txt +1 -0
  10. socratic_debug-0.0.1/socratic_debug.egg-info/entry_points.txt +2 -0
  11. socratic_debug-0.0.1/socratic_debug.egg-info/requires.txt +7 -0
  12. socratic_debug-0.0.1/socratic_debug.egg-info/top_level.txt +3 -0
  13. socratic_debug-0.0.1/src/__init__.py +1 -0
  14. socratic_debug-0.0.1/src/agent/graph/graph.py +47 -0
  15. socratic_debug-0.0.1/src/agent/llm/factory.py +15 -0
  16. socratic_debug-0.0.1/src/agent/llm/providers/__init__.py +8 -0
  17. socratic_debug-0.0.1/src/agent/llm/providers/ollama.py +13 -0
  18. socratic_debug-0.0.1/src/agent/llm/providers/openrouter.py +14 -0
  19. socratic_debug-0.0.1/src/agent/nodes/diagnose_node.py +21 -0
  20. socratic_debug-0.0.1/src/agent/nodes/evaluate_node.py +38 -0
  21. socratic_debug-0.0.1/src/agent/nodes/human_input_node.py +18 -0
  22. socratic_debug-0.0.1/src/agent/nodes/questioner_node.py +47 -0
  23. socratic_debug-0.0.1/src/agent/nodes/solution_node.py +36 -0
  24. socratic_debug-0.0.1/src/agent/prompts/diagnose_prompt.py +34 -0
  25. socratic_debug-0.0.1/src/agent/prompts/evaluation_prompt.py +33 -0
  26. socratic_debug-0.0.1/src/agent/prompts/mentor_prompt.py +30 -0
  27. socratic_debug-0.0.1/src/agent/prompts/questioner_prompt.py +47 -0
  28. socratic_debug-0.0.1/src/agent/prompts/solution_prompt.py +38 -0
  29. socratic_debug-0.0.1/src/agent/runner.py +21 -0
  30. socratic_debug-0.0.1/src/agent/state/state.py +21 -0
  31. socratic_debug-0.0.1/src/cli.py +98 -0
  32. socratic_debug-0.0.1/src/config_creator.py +32 -0
  33. socratic_debug-0.0.1/src/config_template.py +21 -0
  34. socratic_debug-0.0.1/src/extractor.py +34 -0
  35. socratic_debug-0.0.1/src/hook.py +67 -0
  36. socratic_debug-0.0.1/src/utils/read_yaml.py +36 -0
  37. socratic_debug-0.0.1/test/test_hock.py +32 -0
  38. socratic_debug-0.0.1/ui/__init__.py +15 -0
  39. socratic_debug-0.0.1/ui/app.py +203 -0
  40. socratic_debug-0.0.1/ui/bidi.py +23 -0
  41. socratic_debug-0.0.1/ui/console.py +23 -0
  42. socratic_debug-0.0.1/ui/styles.py +63 -0
  43. socratic_debug-0.0.1/ui/templates.py +102 -0
  44. socratic_debug-0.0.1/ui/translations.py +31 -0
  45. socratic_debug-0.0.1/ui/views.py +52 -0
  46. socratic_debug-0.0.1/ui/window.py +140 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohamed Alawakey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: socratic-debug
3
+ Version: 0.0.1
4
+ Summary: Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith
5
+ Author: Mohamed Elawakey
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: pyyaml>=6.0
10
+ Requires-Dist: rich>=13.7.0
11
+ Requires-Dist: PyQt6>=6.6.0
12
+ Requires-Dist: langgraph>=1.2.0
13
+ Requires-Dist: langchain>=1.4.0
14
+ Requires-Dist: langchain-ollama>=1.1.0
15
+ Requires-Dist: langchain-openrouter>=0.2.0
16
+ Dynamic: license-file
17
+
18
+ # 🧠 Socratic Debug (`socratic`)
19
+
20
+ > **Stop copying stack traces. Start mastering your bugs.**
21
+ > An autonomous pedagogical debugger and mentor powered by LangGraph, PyQt6, and LangSmith.
22
+
23
+ [![CI](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml/badge.svg)](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
24
+ [![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)
27
+
28
+ ---
29
+
30
+ ## 💡 Why Socratic?
31
+
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.
35
+
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.**
38
+
39
+ ---
40
+
41
+ ## ✨ Features
42
+
43
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal pollution.
44
+ - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
45
+ - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
46
+ - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
47
+ - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
48
+ - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
49
+ - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
50
+
51
+ ---
52
+
53
+ ## 🚀 Quick Start
54
+
55
+ ### Installation
56
+
57
+ The cleanest, recommended way to install `socratic` globally across your system without virtual environment conflicts:
58
+
59
+ ```bash
60
+ # Recommended (isolated global CLI)
61
+ pipx install socratic-debug
62
+
63
+ # Or via standard pip
64
+ pip install socratic-debug
65
+ ```
66
+
67
+ Alternatively, use the one-line install script:
68
+ ```bash
69
+ # Linux & macOS
70
+ curl -sSL https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.sh | bash
71
+
72
+ # Windows (PowerShell)
73
+ irm https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.ps1 | iex
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 🛠️ Usage
79
+
80
+ You can use `socratic` in two distinct ways:
81
+
82
+ ### Method 1: Zero-Code-Change CLI Runner (Recommended)
83
+ You don't need to add any code or imports to your script! Simply prefix your execution:
84
+
85
+ ```bash
86
+ socratic run my_script.py
87
+ ```
88
+ - If your script runs successfully, it outputs normally.
89
+ - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
90
+
91
+ ### Method 2: In-Process Runtime Hook
92
+ If you are building an application or library and want Socratic guidance baked directly into development runs:
93
+
94
+ ```python
95
+ import socratic
96
+ socratic.install()
97
+
98
+ # Your regular application code
99
+ number_1 = 10
100
+ number_2 = 0
101
+ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
102
+ ```
103
+
104
+ ---
105
+
106
+ ## ⚙️ Configuration (`.socratic.yaml`)
107
+
108
+ When you run `socratic` for the first time, it automatically creates a `.socratic.yaml` config file in your project or home directory:
109
+
110
+ ```yaml
111
+ # LLM Provider: "ollama" or "openrouter"
112
+ provider: "ollama"
113
+ provider_name: "gemma4:31b-cloud"
114
+ provider_link: "http://localhost:11434"
115
+
116
+ # API Key (for cloud providers like OpenRouter)
117
+ api_key: "your_api_key_here"
118
+
119
+ # Mentor Personality & Language ("Arabic" or "English")
120
+ socratic_language: "Arabic"
121
+ socratic_style: "friendly"
122
+
123
+ # Observability with LangSmith (Optional)
124
+ LANGSMITH_TRACING: "true"
125
+ LANGSMITH_API_KEY: "lsv2_pt_..."
126
+ LANGSMITH_PROJECT: "socratic-debug"
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🤝 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.
136
+
137
+ Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
138
+
139
+ ---
140
+
141
+ ## 📄 License
142
+
143
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
@@ -0,0 +1,126 @@
1
+ # 🧠 Socratic Debug (`socratic`)
2
+
3
+ > **Stop copying stack traces. Start mastering your bugs.**
4
+ > An autonomous pedagogical debugger and mentor powered by LangGraph, PyQt6, and LangSmith.
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-blue)](https://www.python.org/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
10
+
11
+ ---
12
+
13
+ ## 💡 Why Socratic?
14
+
15
+ When a runtime crash happens, most developers find themselves trapped in one of two extremes:
16
+ 1. **The Intimidating Traceback:** Staring at a terrifying wall of 50-line red terminal text, unsure which line actually caused the root flaw.
17
+ 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.
18
+
19
+ **Socratic Debug changes the game.**
20
+ 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.**
21
+
22
+ ---
23
+
24
+ ## ✨ Features
25
+
26
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal pollution.
27
+ - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
28
+ - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
29
+ - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
30
+ - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
31
+ - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
32
+ - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
33
+
34
+ ---
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ### Installation
39
+
40
+ The cleanest, recommended way to install `socratic` globally across your system without virtual environment conflicts:
41
+
42
+ ```bash
43
+ # Recommended (isolated global CLI)
44
+ pipx install socratic-debug
45
+
46
+ # Or via standard pip
47
+ pip install socratic-debug
48
+ ```
49
+
50
+ Alternatively, use the one-line install script:
51
+ ```bash
52
+ # Linux & macOS
53
+ curl -sSL https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.sh | bash
54
+
55
+ # Windows (PowerShell)
56
+ irm https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.ps1 | iex
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 🛠️ Usage
62
+
63
+ You can use `socratic` in two distinct ways:
64
+
65
+ ### Method 1: Zero-Code-Change CLI Runner (Recommended)
66
+ You don't need to add any code or imports to your script! Simply prefix your execution:
67
+
68
+ ```bash
69
+ socratic run my_script.py
70
+ ```
71
+ - If your script runs successfully, it outputs normally.
72
+ - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
73
+
74
+ ### Method 2: In-Process Runtime Hook
75
+ If you are building an application or library and want Socratic guidance baked directly into development runs:
76
+
77
+ ```python
78
+ import socratic
79
+ socratic.install()
80
+
81
+ # Your regular application code
82
+ number_1 = 10
83
+ number_2 = 0
84
+ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
85
+ ```
86
+
87
+ ---
88
+
89
+ ## ⚙️ Configuration (`.socratic.yaml`)
90
+
91
+ When you run `socratic` for the first time, it automatically creates a `.socratic.yaml` config file in your project or home directory:
92
+
93
+ ```yaml
94
+ # LLM Provider: "ollama" or "openrouter"
95
+ provider: "ollama"
96
+ provider_name: "gemma4:31b-cloud"
97
+ provider_link: "http://localhost:11434"
98
+
99
+ # API Key (for cloud providers like OpenRouter)
100
+ api_key: "your_api_key_here"
101
+
102
+ # Mentor Personality & Language ("Arabic" or "English")
103
+ socratic_language: "Arabic"
104
+ socratic_style: "friendly"
105
+
106
+ # Observability with LangSmith (Optional)
107
+ LANGSMITH_TRACING: "true"
108
+ LANGSMITH_API_KEY: "lsv2_pt_..."
109
+ LANGSMITH_PROJECT: "socratic-debug"
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 🤝 Contributing
115
+
116
+ We welcome contributions! Please review our [CONTRIBUTING.md](CONTRIBUTING.md) guidelines:
117
+ - For large architectural changes or new features, **please open a GitHub Discussion first**.
118
+ - For minor bug fixes, direct Pull Requests are warmly welcome.
119
+
120
+ Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
121
+
122
+ ---
123
+
124
+ ## 📄 License
125
+
126
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "socratic-debug"
7
+ version = "0.0.1"
8
+ description = "Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith"
9
+ authors = [{ name = "Mohamed Elawakey" }]
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "pyyaml>=6.0",
14
+ "rich>=13.7.0",
15
+ "PyQt6>=6.6.0",
16
+ "langgraph>=1.2.0",
17
+ "langchain>=1.4.0",
18
+ "langchain-ollama>=1.1.0",
19
+ "langchain-openrouter>=0.2.0",
20
+ ]
21
+
22
+ [project.scripts]
23
+ socratic = "src.cli:main"
24
+
25
+ [tool.setuptools]
26
+ py-modules = ["socratic"]
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["."]
30
+ include = ["src*", "ui*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """
2
+ Socratic Debug — Autonomous pedagogical debugging mentor.
3
+ """
4
+
5
+ from src.hook import install
6
+ from src.agent.runner import run_socratic_agent
7
+
8
+ __all__ = ["install", "run_socratic_agent"]
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: socratic-debug
3
+ Version: 0.0.1
4
+ Summary: Autonomous pedagogical debugging mentor powered by LangGraph, Rich, and LangSmith
5
+ Author: Mohamed Elawakey
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: pyyaml>=6.0
10
+ Requires-Dist: rich>=13.7.0
11
+ Requires-Dist: PyQt6>=6.6.0
12
+ Requires-Dist: langgraph>=1.2.0
13
+ Requires-Dist: langchain>=1.4.0
14
+ Requires-Dist: langchain-ollama>=1.1.0
15
+ Requires-Dist: langchain-openrouter>=0.2.0
16
+ Dynamic: license-file
17
+
18
+ # 🧠 Socratic Debug (`socratic`)
19
+
20
+ > **Stop copying stack traces. Start mastering your bugs.**
21
+ > An autonomous pedagogical debugger and mentor powered by LangGraph, PyQt6, and LangSmith.
22
+
23
+ [![CI](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml/badge.svg)](https://github.com/mohamedelawakey/socratic/actions/workflows/ci.yml)
24
+ [![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)
27
+
28
+ ---
29
+
30
+ ## 💡 Why Socratic?
31
+
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.
35
+
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.**
38
+
39
+ ---
40
+
41
+ ## ✨ Features
42
+
43
+ - 🖥️ **Standalone Desktop Window:** Launches an isolated, dark-themed GUI terminal window right at the center of your screen. No terminal pollution.
44
+ - 🌍 **Pure Native BiDi & Arabic Support:** Flawlessly displays English and Arabic with full Right-to-Left (RTL) text shaping and formatting.
45
+ - 🎯 **Calibrated Socratic Mentorship:** 3-tier adaptive hints (Observation ➔ Mechanism ➔ Idiomatic Prevention).
46
+ - 🧠 **Smart Evaluator:** Distinguishes between partial observations (e.g., stating a variable's value) and true comprehension before unlocking the defensive code solution.
47
+ - 🔌 **Universal LLM Support:** Plug into local models via **Ollama** (Gemma, Llama, Qwen) or cloud providers via **OpenRouter** / **Google Gemini**.
48
+ - 📊 **Built-in Observability:** Native tracing with **LangSmith** to monitor latency, tokens, and node execution graphs.
49
+ - 🌐 **Cross-Platform:** Runs seamlessly on **Linux**, **macOS**, and **Windows**.
50
+
51
+ ---
52
+
53
+ ## 🚀 Quick Start
54
+
55
+ ### Installation
56
+
57
+ The cleanest, recommended way to install `socratic` globally across your system without virtual environment conflicts:
58
+
59
+ ```bash
60
+ # Recommended (isolated global CLI)
61
+ pipx install socratic-debug
62
+
63
+ # Or via standard pip
64
+ pip install socratic-debug
65
+ ```
66
+
67
+ Alternatively, use the one-line install script:
68
+ ```bash
69
+ # Linux & macOS
70
+ curl -sSL https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.sh | bash
71
+
72
+ # Windows (PowerShell)
73
+ irm https://raw.githubusercontent.com/mohamedelawakey/socratic/main/install.ps1 | iex
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 🛠️ Usage
79
+
80
+ You can use `socratic` in two distinct ways:
81
+
82
+ ### Method 1: Zero-Code-Change CLI Runner (Recommended)
83
+ You don't need to add any code or imports to your script! Simply prefix your execution:
84
+
85
+ ```bash
86
+ socratic run my_script.py
87
+ ```
88
+ - If your script runs successfully, it outputs normally.
89
+ - If an unhandled exception occurs, the **Socratic Mentor Window** springs to life immediately!
90
+
91
+ ### Method 2: In-Process Runtime Hook
92
+ If you are building an application or library and want Socratic guidance baked directly into development runs:
93
+
94
+ ```python
95
+ import socratic
96
+ socratic.install()
97
+
98
+ # Your regular application code
99
+ number_1 = 10
100
+ number_2 = 0
101
+ print(number_1 / number_2) # <-- ZeroDivisionError triggers Socratic window!
102
+ ```
103
+
104
+ ---
105
+
106
+ ## ⚙️ Configuration (`.socratic.yaml`)
107
+
108
+ When you run `socratic` for the first time, it automatically creates a `.socratic.yaml` config file in your project or home directory:
109
+
110
+ ```yaml
111
+ # LLM Provider: "ollama" or "openrouter"
112
+ provider: "ollama"
113
+ provider_name: "gemma4:31b-cloud"
114
+ provider_link: "http://localhost:11434"
115
+
116
+ # API Key (for cloud providers like OpenRouter)
117
+ api_key: "your_api_key_here"
118
+
119
+ # Mentor Personality & Language ("Arabic" or "English")
120
+ socratic_language: "Arabic"
121
+ socratic_style: "friendly"
122
+
123
+ # Observability with LangSmith (Optional)
124
+ LANGSMITH_TRACING: "true"
125
+ LANGSMITH_API_KEY: "lsv2_pt_..."
126
+ LANGSMITH_PROJECT: "socratic-debug"
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🤝 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.
136
+
137
+ Please note that this project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
138
+
139
+ ---
140
+
141
+ ## 📄 License
142
+
143
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
@@ -0,0 +1,44 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ socratic.py
5
+ socratic_debug.egg-info/PKG-INFO
6
+ socratic_debug.egg-info/SOURCES.txt
7
+ socratic_debug.egg-info/dependency_links.txt
8
+ socratic_debug.egg-info/entry_points.txt
9
+ socratic_debug.egg-info/requires.txt
10
+ socratic_debug.egg-info/top_level.txt
11
+ src/__init__.py
12
+ src/cli.py
13
+ src/config_creator.py
14
+ src/config_template.py
15
+ src/extractor.py
16
+ src/hook.py
17
+ src/agent/runner.py
18
+ src/agent/graph/graph.py
19
+ src/agent/llm/factory.py
20
+ src/agent/llm/providers/__init__.py
21
+ src/agent/llm/providers/ollama.py
22
+ src/agent/llm/providers/openrouter.py
23
+ src/agent/nodes/diagnose_node.py
24
+ src/agent/nodes/evaluate_node.py
25
+ src/agent/nodes/human_input_node.py
26
+ src/agent/nodes/questioner_node.py
27
+ src/agent/nodes/solution_node.py
28
+ src/agent/prompts/diagnose_prompt.py
29
+ src/agent/prompts/evaluation_prompt.py
30
+ src/agent/prompts/mentor_prompt.py
31
+ src/agent/prompts/questioner_prompt.py
32
+ src/agent/prompts/solution_prompt.py
33
+ src/agent/state/state.py
34
+ src/utils/read_yaml.py
35
+ test/test_hock.py
36
+ ui/__init__.py
37
+ ui/app.py
38
+ ui/bidi.py
39
+ ui/console.py
40
+ ui/styles.py
41
+ ui/templates.py
42
+ ui/translations.py
43
+ ui/views.py
44
+ ui/window.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ socratic = src.cli:main
@@ -0,0 +1,7 @@
1
+ pyyaml>=6.0
2
+ rich>=13.7.0
3
+ PyQt6>=6.6.0
4
+ langgraph>=1.2.0
5
+ langchain>=1.4.0
6
+ langchain-ollama>=1.1.0
7
+ langchain-openrouter>=0.2.0
@@ -0,0 +1,3 @@
1
+ socratic
2
+ src
3
+ ui
@@ -0,0 +1 @@
1
+ # socratic package
@@ -0,0 +1,47 @@
1
+ from langgraph.graph import StateGraph, END, START
2
+ from src.agent.state.state import SocraticAgentState
3
+ from src.agent.nodes.diagnose_node import DiagnoseNode
4
+ from src.agent.nodes.questioner_node import QuestionerNode
5
+ from src.agent.nodes.human_input_node import HumanInputNode
6
+ from src.agent.nodes.evaluate_node import EvaluationNode
7
+ from src.agent.nodes.solution_node import SolutionNode
8
+
9
+ def decision_router(state: SocraticAgentState) -> str:
10
+ if state.get("is_solved"):
11
+ return "solution"
12
+ if state.get("hint_level", 1) > 3:
13
+ return "solution"
14
+ return "questioner"
15
+
16
+
17
+ class SocraticGraph:
18
+ @staticmethod
19
+ def build_graph():
20
+ # We will assemble nodes and edges here
21
+ graph = StateGraph(SocraticAgentState)
22
+
23
+ # add nodes
24
+ graph.add_node("diagnose", DiagnoseNode.diagnose_node)
25
+ graph.add_node("questioner", QuestionerNode.questioner_node)
26
+ graph.add_node("human_input", HumanInputNode.human_input_node)
27
+ graph.add_node("evaluate", EvaluationNode.evaluation_node)
28
+ graph.add_node("solution", SolutionNode.solution_node)
29
+
30
+ # edges
31
+ graph.add_edge(START, "diagnose")
32
+ graph.add_edge("diagnose", "questioner")
33
+ graph.add_edge("questioner", "human_input")
34
+ graph.add_edge("human_input", "evaluate")
35
+
36
+ graph.add_conditional_edges(
37
+ "evaluate",
38
+ decision_router,
39
+ {
40
+ "solution": "solution",
41
+ "questioner": "questioner",
42
+ }
43
+ )
44
+ graph.add_edge("solution", END)
45
+
46
+ return graph.compile()
47
+
@@ -0,0 +1,15 @@
1
+ from src.agent.llm.providers import *
2
+ from src.utils.read_yaml import ReadYaml
3
+
4
+
5
+ class LLMFactory:
6
+ @staticmethod
7
+ def get_llm():
8
+ config = ReadYaml.read_yaml()
9
+
10
+ if config["provider"] == "openrouter":
11
+ return OpenRouterLLM.openrouter_llm()
12
+ elif config["provider"] == "ollama":
13
+ return OllamaLLM.ollama_llm()
14
+ else:
15
+ raise ValueError("Invalid provider")
@@ -0,0 +1,8 @@
1
+ from src.agent.llm.providers.openrouter import OpenRouterLLM
2
+ from src.agent.llm.providers.ollama import OllamaLLM
3
+
4
+
5
+ __all__ = [
6
+ "OpenRouterLLM",
7
+ "OllamaLLM",
8
+ ]
@@ -0,0 +1,13 @@
1
+ from langchain_ollama import ChatOllama
2
+ from src.utils.read_yaml import ReadYaml
3
+
4
+
5
+ class OllamaLLM:
6
+ @staticmethod
7
+ def ollama_llm():
8
+ config = ReadYaml.read_yaml()
9
+
10
+ return ChatOllama (
11
+ model=config["provider_name"],
12
+ base_url=config["provider_link"],
13
+ )
@@ -0,0 +1,14 @@
1
+ from langchain_openrouter import ChatOpenRouter
2
+ from src.utils.read_yaml import ReadYaml
3
+
4
+
5
+ class OpenRouterLLM:
6
+ @staticmethod
7
+ def openrouter_llm():
8
+ config = ReadYaml.read_yaml()
9
+
10
+ return ChatOpenRouter(
11
+ model=config["provider_name"],
12
+ base_url=config["provider_link"],
13
+ api_key=config["api_key"],
14
+ )
@@ -0,0 +1,21 @@
1
+ from src.agent.prompts.diagnose_prompt import DiagnosePrompt
2
+ from src.agent.state.state import SocraticAgentState
3
+ from src.agent.llm.factory import LLMFactory
4
+
5
+
6
+ class DiagnoseNode:
7
+ @staticmethod
8
+ def diagnose_node(state: SocraticAgentState) -> dict:
9
+ prompt = DiagnosePrompt.diagnose_prompt(
10
+ error_type=state["error_type"],
11
+ error_name=state["error_name"],
12
+ file_path=state["file_path"],
13
+ line_number=state["line_number"],
14
+ line_content=state["line_content"],
15
+ code_snippet=state["code_snippet"],
16
+ function_name=state.get("function_name") or "",
17
+ )
18
+
19
+ response = LLMFactory.get_llm().invoke(prompt)
20
+
21
+ return {"root_cause": response.content}