claude-sdk-tutor 0.1.0__py3-none-any.whl

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.
app.py ADDED
@@ -0,0 +1,134 @@
1
+ import json
2
+
3
+ from claude_agent_sdk import AssistantMessage, ResultMessage
4
+ from rich.markdown import Markdown as RichMarkdown
5
+ from rich.panel import Panel
6
+ from textual.app import App, ComposeResult
7
+ from textual.containers import Vertical
8
+ from textual.widgets import Static, Footer, Input, RichLog, LoadingIndicator
9
+
10
+ from claude.claude_agent import (
11
+ connect_client,
12
+ create_claude_client,
13
+ stream_helpful_claude,
14
+ )
15
+
16
+
17
+ class MyApp(App):
18
+ def __init__(self):
19
+ super().__init__()
20
+ self.tutor_mode = True
21
+ self.client = create_claude_client(tutor_mode=self.tutor_mode)
22
+
23
+ CSS = """
24
+ #main {
25
+ height: 100%;
26
+ }
27
+ Input {
28
+ height: auto;
29
+ margin-top: 1;
30
+ margin-left: 3;
31
+ margin-right: 3;
32
+ margin-bottom: 1;
33
+ }
34
+ #header {
35
+ content-align: center middle;
36
+ width: 100%;
37
+ margin-top: 1;
38
+ margin-bottom: 1;
39
+ height: auto;
40
+ }
41
+ RichLog {
42
+ background: $boost;
43
+ margin-left: 3;
44
+ margin-right: 3;
45
+ height: 1fr;
46
+ }
47
+ LoadingIndicator {
48
+ height: auto;
49
+ margin-left: 3;
50
+ margin-right: 3;
51
+ }
52
+ """
53
+
54
+ def compose(self) -> ComposeResult:
55
+ with Vertical(id="main"):
56
+ yield Static("Welcome to claude tutor!", id="header")
57
+ yield RichLog(markup=True, highlight=True)
58
+ yield LoadingIndicator(id="spinner")
59
+ yield Input()
60
+ yield Footer()
61
+
62
+ async def on_mount(self) -> None:
63
+ self.query_one("#spinner", LoadingIndicator).display = False
64
+ await connect_client(self.client)
65
+
66
+ def write_user_message(self, message: str) -> None:
67
+ log = self.query_one(RichLog)
68
+ log.write(Panel(RichMarkdown(message), title="You", border_style="bright_blue"))
69
+
70
+ def write_system_message(self, message: str) -> None:
71
+ log = self.query_one(RichLog)
72
+ log.write(Panel(RichMarkdown(message), title="Claude", border_style="red"))
73
+
74
+ def write_tool_message(self, name: str, input: dict) -> None:
75
+ log = self.query_one(RichLog)
76
+ input_str = json.dumps(input, indent=2)
77
+ content = f"**{name}**\n```json\n{input_str}\n```"
78
+ log.write(Panel(RichMarkdown(content), title="Tool", border_style="grey50"))
79
+
80
+ def write_slash_message(self, message: str) -> None:
81
+ log = self.query_one(RichLog)
82
+ log.write(Panel(RichMarkdown(message), title="Slash", border_style="green"))
83
+
84
+ def on_input_submitted(self, event: Input.Submitted) -> None:
85
+ self.query_one(Input).value = ""
86
+ command = event.value.strip()
87
+ if command == "/clear":
88
+ self.run_worker(self.clear_conversation())
89
+ return
90
+ if command == "/tutor":
91
+ self.run_worker(self.toggle_tutor_mode())
92
+ return
93
+ self.write_user_message(event.value)
94
+ self.query_one("#spinner", LoadingIndicator).display = True
95
+ self.run_worker(self.get_response(event.value))
96
+
97
+ async def clear_conversation(self) -> None:
98
+ self.query_one(RichLog).clear()
99
+ self.client = create_claude_client(tutor_mode=self.tutor_mode)
100
+ await connect_client(self.client)
101
+ self.write_slash_message("Context cleared")
102
+
103
+ async def toggle_tutor_mode(self) -> None:
104
+ self.tutor_mode = not self.tutor_mode
105
+ self.query_one(RichLog).clear()
106
+ self.client = create_claude_client(tutor_mode=self.tutor_mode)
107
+ await connect_client(self.client)
108
+ status = "on" if self.tutor_mode else "off"
109
+ self.write_slash_message(f"Tutor mode {status}")
110
+
111
+ async def get_response(self, text: str) -> None:
112
+ try:
113
+ async for message in stream_helpful_claude(self.client, text):
114
+ if isinstance(message, AssistantMessage):
115
+ for block in message.content:
116
+ if hasattr(block, "text"):
117
+ self.write_system_message(block.text)
118
+ elif hasattr(block, "name"):
119
+ self.write_tool_message(
120
+ block.name, getattr(block, "input", {})
121
+ )
122
+ elif isinstance(message, ResultMessage):
123
+ pass # Might want to add logging later
124
+ finally:
125
+ self.query_one("#spinner", LoadingIndicator).display = False
126
+
127
+
128
+ def main():
129
+ app = MyApp()
130
+ app.run()
131
+
132
+
133
+ if __name__ == "__main__":
134
+ main()
claude/__init__.py ADDED
File without changes
claude/claude_agent.py ADDED
@@ -0,0 +1,29 @@
1
+ from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
2
+
3
+ TUTOR_SYSTEM_PROMPT = """You are a programming tutor. Your role is to help users learn and understand code, not to write code for them.
4
+
5
+ When a user asks a question:
6
+ - Explain concepts clearly and thoroughly
7
+ - Guide them toward understanding with questions and hints
8
+ - If they're stuck, provide small examples to illustrate concepts
9
+ - Encourage them to write the code themselves
10
+ - Review and explain code they show you, pointing out what works well and what could be improved
11
+
12
+ Never write complete solutions for them. Instead, help them develop the skills to solve problems independently."""
13
+
14
+
15
+ def create_claude_client(tutor_mode: bool = True) -> ClaudeSDKClient:
16
+ options = ClaudeAgentOptions(allowed_tools=["Read", "Glob", "Grep"])
17
+ if tutor_mode:
18
+ options.system_prompt = TUTOR_SYSTEM_PROMPT
19
+ return ClaudeSDKClient(options=options)
20
+
21
+
22
+ async def connect_client(client: ClaudeSDKClient) -> None:
23
+ await client.connect()
24
+
25
+
26
+ async def stream_helpful_claude(client: ClaudeSDKClient, text: str):
27
+ await client.query(prompt=text)
28
+ async for message in client.receive_response():
29
+ yield message
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-sdk-tutor
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: claude-agent-sdk>=0.1.26
8
+ Requires-Dist: textual-dev>=1.8.0
9
+ Requires-Dist: textual>=7.5.0
10
+ Requires-Dist: watchfiles>=1.1.1
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Claude Tutor
14
+
15
+ A terminal-based programming tutor powered by Claude. Built with Textual and the Claude Agent SDK.
16
+
17
+ ## Overview
18
+
19
+ Claude Tutor is a TUI (Terminal User Interface) application designed to help you learn programming concepts. Unlike a typical coding assistant, Claude Tutor focuses on teaching rather than writing code for you. It will:
20
+
21
+ - Explain concepts clearly and thoroughly
22
+ - Guide you toward understanding with questions and hints
23
+ - Provide small examples to illustrate concepts
24
+ - Encourage you to write code yourself
25
+ - Review code you share, pointing out what works well and what could be improved
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ uv sync
31
+ ```
32
+
33
+ Or install from PyPI:
34
+
35
+ ```bash
36
+ uvx claude_tutor
37
+ ```
38
+
39
+ ## Running
40
+
41
+ ```bash
42
+ uv run python app.py
43
+ ```
44
+
45
+ ## Using the TUI
46
+
47
+ When you launch Claude Tutor, you'll see a simple interface with:
48
+
49
+ - A welcome header at the top
50
+ - A chat log area in the middle showing your conversation
51
+ - A text input field at the bottom for typing messages
52
+
53
+ Type your programming questions in the input field and press Enter to send. Claude's responses will appear in the chat log. The interface uses color-coded panels to distinguish between different message types:
54
+
55
+ - **Blue** - Your messages
56
+ - **Red** - Claude's responses
57
+ - **Grey** - Tool usage (when Claude reads files in your codebase)
58
+ - **Green** - Slash command feedback
59
+
60
+ ## Slash Commands
61
+
62
+ | Command | Description |
63
+ |---------|-------------|
64
+ | `/clear` | Clears the conversation history and starts fresh. Your tutor mode setting is preserved. |
65
+ | `/tutor` | Toggles tutor mode on/off. When on (default), Claude acts as a teacher. When off, Claude responds normally without the tutoring constraints. |
66
+
67
+ ## Tech Stack
68
+
69
+ - Python 3.13+
70
+ - [Textual](https://textual.textualize.io/) - TUI framework
71
+ - [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk) - Claude integration
72
+ - [uv](https://github.com/astral-sh/uv) - Package manager
@@ -0,0 +1,8 @@
1
+ app.py,sha256=rAnlcXNQmZiRiqixJISAkzSBWuBrPssjKbGuRngAOY8,4457
2
+ claude/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ claude/claude_agent.py,sha256=8stg0rHC7g3b5CqS3EdvwkBMQqqZ0McHzlthMdIWlgE,1187
4
+ claude_sdk_tutor-0.1.0.dist-info/METADATA,sha256=wHBRljVm9H5yuk74I3W03f5gJLUDJlatSUnq6GO2I80,2247
5
+ claude_sdk_tutor-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ claude_sdk_tutor-0.1.0.dist-info/entry_points.txt,sha256=w-2yw_mHAwLUFSBVEKl_uQ9HnyYHd9c5glCrmgVeMyw,42
7
+ claude_sdk_tutor-0.1.0.dist-info/licenses/LICENSE,sha256=KzxybQVVAEGBifrjNj5OGwQ_rsbzCIGPm0xrTL6-VZs,1067
8
+ claude_sdk_tutor-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ claude_tutor = app:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ryan Wiley
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.