koder 0.3.0__py3-none-any.whl → 0.3.2__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.
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.4
2
+ Name: koder
3
+ Version: 0.3.2
4
+ Summary: An intuitive AI coding assistant and interactive CLI tool that boosts developer productivity with intelligent automation and context-aware support.
5
+ Project-URL: Homepage, https://github.com/feiskyer/koder
6
+ Project-URL: Repository, https://github.com/feiskyer/koder
7
+ Author: Pengfei Ni
8
+ License-File: LICENSE
9
+ Keywords: agent,agentic,ai,copilot,litellm,openai,vibe coding
10
+ Requires-Python: >=3.9
11
+ Requires-Dist: aiosqlite>=0.19.0
12
+ Requires-Dist: apscheduler>=3.11.0
13
+ Requires-Dist: backoff>=2.2.1
14
+ Requires-Dist: beautifulsoup4>=4.12.0
15
+ Requires-Dist: cryptography>=45.0.6
16
+ Requires-Dist: fastapi-sso>=0.18.0
17
+ Requires-Dist: fastapi>=0.116.1
18
+ Requires-Dist: google-cloud-aiplatform>=1.106.0
19
+ Requires-Dist: httpx[socks]>=0.25.0
20
+ Requires-Dist: openai-agents[litellm]>=0.2.4
21
+ Requires-Dist: openai==1.98.0
22
+ Requires-Dist: orjson>=3.11.2
23
+ Requires-Dist: prompt-toolkit>=3.0.51
24
+ Requires-Dist: pydantic>=2.0.0
25
+ Requires-Dist: pyjwt>=2.10.1
26
+ Requires-Dist: pynacl>=1.5.0
27
+ Requires-Dist: python-multipart>=0.0.20
28
+ Requires-Dist: requests>=2.31.0
29
+ Requires-Dist: rich>=14.1.0
30
+ Requires-Dist: tiktoken>=0.5.0
31
+ Requires-Dist: websockets>=15.0.1
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Koder
35
+
36
+ [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![PyPI Downloads](https://static.pepy.tech/badge/koder)](https://pepy.tech/projects/koder)
37
+
38
+ Koder is an experimental, universal AI coding assistant designed to explore how to build an advanced terminal-based AI coding assistant. Written entirely in Python, it serves as both a functional tool and a learning playground for AI agent development.
39
+
40
+ **🎯 Project Status**: Under active vibe coding! This is a learning-focused project where we explore building AI coding agents.
41
+
42
+ ## ✨ Features
43
+
44
+ - **🤖 Universal AI Support**: Works with OpenAI, Anthropic, Google, GitHub Copilot, and 100+ providers via LiteLLM with intelligent auto-detection
45
+ - **💾 Smart Context Management**: Persistent sessions with SQLite storage and automatic token-aware compression (50k token limit)
46
+ - **🔄 Real-time Streaming**: Rich Live displays with intelligent terminal cleanup for responsive user experience
47
+ - **🛠️ Comprehensive Toolset**: file operations, search, shell, task delegation and todos.
48
+ - **🔌 MCP Integration**: Model Context Protocol support with stdio, SSE, and HTTP transports for extensible tool ecosystem
49
+ - **🛡️ Enterprise Security**: SecurityGuard validation, output filtering, permission system, and input sanitization
50
+ - **🎯 Zero Configuration**: Automatic provider detection with fallback defaults
51
+
52
+ ## 🛠️ Installation
53
+
54
+ ### Using uv (Recommended)
55
+
56
+ ```sh
57
+ uv tool install koder
58
+ ```
59
+
60
+ ### Using pip
61
+
62
+ ```bash
63
+ pip install koder
64
+ ```
65
+
66
+ ## ⚡ Quick Start
67
+
68
+ Simply run Koder with your question or request:
69
+
70
+ ```bash
71
+ # Configure one provider (example: OpenAI)
72
+ export OPENAI_API_KEY="your-openai-api-key"
73
+ export KODER_MODEL="gpt-4o"
74
+
75
+ # Run in interactive mode
76
+ koder
77
+
78
+ # Run with prompt
79
+ koder "create a Python function to calculate fibonacci numbers"
80
+
81
+ # Execute a single prompt in a named session
82
+ koder -s my-project "Help me implement a new feature"
83
+
84
+ # Use an explicit session flag
85
+ koder -s my-project "Your prompt here"
86
+ ```
87
+
88
+ ## 🤖 Configuration
89
+
90
+ ### Environment Variables
91
+
92
+ Koder automatically detects your AI provider based on available environment variables. The `KODER_MODEL` environment variable controls which model to use:
93
+
94
+ ```bash
95
+ # OpenAI models
96
+ export KODER_MODEL="gpt-4.1"
97
+ koder
98
+
99
+ # Claude models (via LiteLLM)
100
+ export KODER_MODEL="claude-opus-4-20250514"
101
+ export ANTHROPIC_API_KEY=your-api-key
102
+ koder
103
+
104
+ # Google Gemini models (via LiteLLM)
105
+ export KODER_MODEL="gemini/gemini-2.5-pro"
106
+ export GOOGLE_API_KEY=your-api-key
107
+ koder
108
+
109
+ # Github Copilot (via LiteLLM)
110
+ export KODER_MODEL="github_copilot/claude-sonnet-4"
111
+ koder
112
+ ```
113
+
114
+ ### Supported Providers
115
+
116
+ <details>
117
+ <summary><b>OpenAI</b></summary>
118
+
119
+ ```bash
120
+ export OPENAI_API_KEY=your-api-key
121
+
122
+ # Optional: Use custom endpoint
123
+ export OPENAI_API_BASE=https://your-endpoint.com
124
+
125
+ # Optional: Specify model (default: gpt-4.1)
126
+ export KODER_MODEL="gpt-4o"
127
+
128
+ koder
129
+ ```
130
+
131
+ </details>
132
+
133
+ <details>
134
+ <summary><b>Anthropic</b></summary>
135
+
136
+ ```bash
137
+ export KODER_MODEL="claude-opus-4-20250514"
138
+ export ANTHROPIC_API_KEY=your-api-key
139
+ koder
140
+ ```
141
+
142
+ </details>
143
+
144
+ <details>
145
+ <summary><b>Google Gemini</b></summary>
146
+
147
+ ```bash
148
+ export KODER_MODEL="gemini/gemini-2.5-pro"
149
+ export GOOGLE_API_KEY=your-api-key
150
+ koder
151
+ ```
152
+
153
+ </details>
154
+
155
+ <details>
156
+ <summary><b>GitHub Copilot</b></summary>
157
+
158
+ ```bash
159
+ export KODER_MODEL="github_copilot/claude-sonnet-4"
160
+ koder
161
+ ```
162
+
163
+ On first run you will see a device code in the terminal. Visit <https://github.com/login/device> and enter the code to authenticate.
164
+
165
+ </details>
166
+
167
+ <details>
168
+ <summary><b>Azure OpenAI</b></summary>
169
+
170
+ ```bash
171
+ export KODER_MODEL=azure/gpt-5
172
+ export AZURE_API_KEY="your-azure-api-key"
173
+ export ZURE_API_BASE="https://your-resource.openai.azure.com"
174
+ export AZURE_API_VERSION="2025-04-01-preview"
175
+ koder
176
+ ```
177
+
178
+ </details>
179
+
180
+ <details>
181
+ <summary><b>Other AI providers (via LiteLLM)</b></summary>
182
+
183
+ [LiteLLM](https://docs.litellm.ai/docs/providers) supports 100+ providers including Anthropic, Google, Cohere, Hugging Face, and more:
184
+
185
+ ```bash
186
+ # Google Vertex AI
187
+ export KODER_MODEL="vertex_ai/claude-sonnet-4@20250514"
188
+ export GOOGLE_APPLICATION_CREDENTIALS="your-sa-path.json"
189
+ export VERTEXAI_LOCATION="<your-region>"
190
+ koder
191
+
192
+ # Custom OpenAI-compatible endpoints
193
+ export KODER_MODEL="openai/<your-model-name>"
194
+ export OPENAI_API_KEY="your-key"
195
+ export OPENAI_BASE_URL="https://your-custom-endpoint.com/v1"
196
+ koder
197
+ ```
198
+
199
+ </details>
200
+
201
+ ## 🛠️ Development
202
+
203
+ ### Setup Development Environment
204
+
205
+ ```bash
206
+ # Clone the repository
207
+ git clone https://github.com/feiskyer/koder.git
208
+ cd koder
209
+
210
+ uv sync
211
+ uv run koder
212
+ ```
213
+
214
+ ### Code Quality
215
+
216
+ ```bash
217
+ # Code formatting
218
+ black .
219
+
220
+ # Linting
221
+ ruff check --fix
222
+
223
+ # pylint
224
+ pylint koder_agent/ --disable=C,R,W --errors-only
225
+ ```
226
+
227
+ ## 🔒 Security
228
+
229
+ - **API Keys**: All API keys are stored in environment variables and never in code.
230
+ - **Local Storage**: Sessions are stored locally in your home directory.
231
+ - **No Telemetry**: Koder doesn't send any data besides API requests to your chosen provider.
232
+ - **Code Execution**: Shell commands require explicit user confirmation.
233
+
234
+ ## 🤝 Contributing
235
+
236
+ Contributions are welcome! Here's how you can help:
237
+
238
+ 1. **Fork** the repository
239
+ 2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
240
+ 3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
241
+ 4. **Push** to the branch (`git push origin feature/amazing-feature`)
242
+ 5. **Open** a Pull Request
243
+
244
+ Please read our [Contributing Guidelines](CONTRIBUTING.md) for more details.
245
+
246
+ ## 🌐 Code of Conduct
247
+
248
+ This project follows a Code of Conduct based on the Contributor Covenant. Be kind and respectful. If you observe unacceptable behavior, please open an issue.
249
+
250
+ ## 📄 License
251
+
252
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
253
+
254
+ Use of third-party AI services is governed by their respective provider terms.
@@ -1,13 +1,15 @@
1
- koder_agent/__init__.py,sha256=pSYS9WRlMlDEf1TJJ8ciELm5TlHhucYR7zKSlaB8iso,171
2
- koder_agent/cli.py,sha256=4K6UZDwMLcFFGGE07jyGkpt61opTE7-IAQ0vuylbLt8,8230
3
- koder_agent/agentic/__init__.py,sha256=gq-1V6gHnuqyoBN_XWJ0Y2J4_4fKZP9lwhwTeQLGwrg,334
1
+ koder_agent/__init__.py,sha256=0i6dNkJxmJ3XYxmBRo06sN3Ihj-jNn9dBfv-M4abBR8,171
2
+ koder_agent/cli.py,sha256=1LynLhtLM2bBjy0cFNyazAKY7IoVVsLQOO4nuNeqokY,9536
3
+ koder_agent/agentic/__init__.py,sha256=uguESvn1OCf_xivyHFjq02wa2T8SvIWhj1WqlvKG0Y8,441
4
4
  koder_agent/agentic/agent.py,sha256=DaEOSxCsnBuj_wWNuUSrEfR98VbiXhHYHj60MIhJ3bI,1308
5
+ koder_agent/agentic/approval_hooks.py,sha256=zql1OsWki8Isjw9AFH5nQJMV7UmnfPz74MDfT7NHtVg,2651
5
6
  koder_agent/agentic/hooks.py,sha256=EV4m6oCp-uwGZ8QGJDJEN_hZJpCoiLhJh8LeMfNR8bU,2336
6
7
  koder_agent/core/__init__.py,sha256=Ez1Yq2tcj8_RjGCXXBcKfJa8QqFiTt4-sh82Kh5-l1I,215
7
- koder_agent/core/commands.py,sha256=j5V4VU9vjshDEvWJ8ZlmTqtFjIQ9EQPH95M2JvYyFy0,9121
8
+ koder_agent/core/commands.py,sha256=guplmFX3zxFDknsM6TnJLD9AY8XDlFKj0ScfT9BVoyI,11161
8
9
  koder_agent/core/context.py,sha256=tCjoki4LkZ37erPONwdG1ZS0fBMdQEJq0XKWtzglhdg,5725
9
- koder_agent/core/interactive.py,sha256=BCK0xYUIhjKiHCdPA0DiYuCDSNM_MkE0NzAEzFHwLrM,9207
10
- koder_agent/core/scheduler.py,sha256=1SmDxYxvq9YDu1pbNIGuM1rahQFa3q39t6NxapWPY50,14907
10
+ koder_agent/core/interactive.py,sha256=io9jB1369SZz9ORSm6O6Hz5QTrHd6qChjiaIoDndtmE,9279
11
+ koder_agent/core/permissions.py,sha256=47W5JuJ6xFbPFyBh3vuzJyAeHl9uqOOwpVwVxvWPcd0,11189
12
+ koder_agent/core/scheduler.py,sha256=jE5Wiq4ZlkQzyfV5_8rZn6PEmW9JfKoJxQE0IcT-3v0,17638
11
13
  koder_agent/core/security.py,sha256=ZLvROGGrbGpnW8UzhEPmH2Q-7IFlDqKZzn3ich2QS1I,2110
12
14
  koder_agent/core/streaming_display.py,sha256=L2QSrLU9XbX5V4uq2nUFdCL90IQSGibV934ToMRUPbI,19480
13
15
  koder_agent/mcp/__init__.py,sha256=FWCGMUZNV_akYU0NkaQlMAPzTWu3f2Orofioyb-Bom8,887
@@ -16,19 +18,20 @@ koder_agent/mcp/server_config.py,sha256=7Uexds0yPObSNnliJ2U9YqqIkW7D_Mvr3BF96G1W
16
18
  koder_agent/mcp/server_factory.py,sha256=otrxU-aLjtZdkljqEH4gSGS__lpaucNM-EhH34f9JX4,5300
17
19
  koder_agent/mcp/server_manager.py,sha256=2QPPtl6I9TpWIJmTUR9OR1zDDHJEUvP9vrPOoee65GA,5786
18
20
  koder_agent/tools/__init__.py,sha256=VplnqKQEeM5OP9QZtltpoH9mfU4OuV2HDjJ06HVDHms,2432
19
- koder_agent/tools/engine.py,sha256=OvsjSchNzOBHrv5Ezms7OU0WC5M3Zi82ju3CWQJYd00,3926
21
+ koder_agent/tools/engine.py,sha256=gqs48Y0J6paBTHmTle79JiT3_gYDI8mDUXFgHYT4lL0,4517
20
22
  koder_agent/tools/file_ops.py,sha256=5VLfuLBFloMGPHbDDs_C8wBqdVlr43QSdjbbyR9d2I8,2975
21
23
  koder_agent/tools/search_ops.py,sha256=7IjC4vAXkdBMIXLRzschanjtKi7PeJBivs0sVqqASdM,4403
22
24
  koder_agent/tools/shell_ops.py,sha256=st3RM6zcEpmfTZrh-waeY_RFaDjBCPf9xqsEEJxLOT0,2514
23
25
  koder_agent/tools/task_ops.py,sha256=r6UQ5byvZU9sy58a_g66QHswS2vHciyS6trxs79Hyj8,3832
24
26
  koder_agent/tools/todo_ops.py,sha256=nRwkQa3v_cP1MW5Z13GTLZCkal8R-1PjzQPX0iGY_oQ,1952
25
27
  koder_agent/tools/web_ops.py,sha256=SaOA3wDx2IqDSeoKj4TaQICenjdioF9eLwnRDhWy16U,4098
26
- koder_agent/utils/__init__.py,sha256=AV-Nq5QqOTAYbfaMECwBF1YflGUNNEdogr3PvVbNWMA,265
27
- koder_agent/utils/client.py,sha256=2ro1nrFBOuSSAZ4B9QbEsPc2ZKClRiRxvLROStsKYwo,2713
28
- koder_agent/utils/prompts.py,sha256=dZUTazx0Gn26HrFhRwGG49VsOT5Wsym7BlgKSgiu96U,10583
28
+ koder_agent/utils/__init__.py,sha256=Ax0HOGqTRH99Fe0mOulDErLQeE5Gyf50qU4-Ij3OINg,487
29
+ koder_agent/utils/client.py,sha256=QrGWw9lUBiy85B8RcWWlSArhNgbKO4gzfs4s_Aiccro,1583
30
+ koder_agent/utils/prompts.py,sha256=oDT4YF6ddSebRtombIT5FJxQW3OQ18aSBzD_krjBAEc,10606
29
31
  koder_agent/utils/queue.py,sha256=5SkAKAYV5kOLSONTTZ5iRNBfIlRu8RiHNX4x8mfK6Y8,1852
30
- koder-0.3.0.dist-info/METADATA,sha256=mZ-hMXVJBCiofYOQiAEvufnD7Xrk26d7pDqmzIiXfAA,5693
31
- koder-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
- koder-0.3.0.dist-info/entry_points.txt,sha256=zSrvnNNCJxbTugC0hDOEp4nBaBIuZG1csOKheYnnk2k,46
33
- koder-0.3.0.dist-info/licenses/LICENSE,sha256=CgdY9dqqgVOJjiXs9gZSRlFU4FpJdG9vbGyPAFug8PQ,1067
34
- koder-0.3.0.dist-info/RECORD,,
32
+ koder_agent/utils/sessions.py,sha256=05aRhoRir66PKaLGW62zBz_4I6rG77y5coW_xhvyS7M,2664
33
+ koder-0.3.2.dist-info/METADATA,sha256=x0iru4ZLxNiTSSGzQljz2DqCZGuOmC_MSP5rTEavP18,7393
34
+ koder-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ koder-0.3.2.dist-info/entry_points.txt,sha256=zSrvnNNCJxbTugC0hDOEp4nBaBIuZG1csOKheYnnk2k,46
36
+ koder-0.3.2.dist-info/licenses/LICENSE,sha256=CgdY9dqqgVOJjiXs9gZSRlFU4FpJdG9vbGyPAFug8PQ,1067
37
+ koder-0.3.2.dist-info/RECORD,,
koder_agent/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Koder Agent - An advanced AI coding assistant and interactive CLI tool."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.3.2"
4
4
 
5
5
  from .cli import main, run
6
6
 
@@ -5,11 +5,14 @@ from .agent import (
5
5
  # create_planner_agent,
6
6
  get_model_name,
7
7
  )
8
+ from .approval_hooks import ApprovalHooks, ToolApprovalError
8
9
  from .hooks import ToolDisplayHooks, get_display_hooks
9
10
 
10
11
  __all__ = [
11
12
  "ToolDisplayHooks",
12
13
  "get_display_hooks",
14
+ "ApprovalHooks",
15
+ "ToolApprovalError",
13
16
  # "create_planner_agent",
14
17
  "create_dev_agent",
15
18
  "get_model_name",
@@ -0,0 +1,66 @@
1
+ """Approval hooks for tool execution."""
2
+
3
+ from typing import Any
4
+
5
+ from agents import Agent, RunContextWrapper, RunHooks, Tool
6
+
7
+ from ..core.permissions import PermissionManager
8
+
9
+
10
+ class ToolApprovalError(Exception):
11
+ """Raised when tool execution is denied."""
12
+
13
+
14
+ class ApprovalHooks(RunHooks):
15
+ """RunHooks implementation that adds approval flow for tool execution."""
16
+
17
+ def __init__(self, permission_manager: PermissionManager, wrapped_hooks: RunHooks):
18
+ """Initialize approval hooks.
19
+
20
+ Args:
21
+ permission_manager: Permission manager instance
22
+ wrapped_hooks: Optional hooks to wrap (e.g., display hooks)
23
+ """
24
+ self.permission_manager = permission_manager
25
+ self.wrapped_hooks = wrapped_hooks
26
+
27
+ async def on_agent_start(self, context: RunContextWrapper, agent: Agent) -> None:
28
+ """Called before the agent is invoked."""
29
+ if self.wrapped_hooks:
30
+ await self.wrapped_hooks.on_agent_start(context, agent)
31
+
32
+ async def on_agent_end(self, context: RunContextWrapper, agent: Agent, output: Any) -> None:
33
+ """Called when the agent produces a final output."""
34
+ if self.wrapped_hooks:
35
+ await self.wrapped_hooks.on_agent_end(context, agent, output)
36
+
37
+ async def on_handoff(
38
+ self, context: RunContextWrapper, from_agent: Agent, to_agent: Agent
39
+ ) -> None:
40
+ """Called when a handoff occurs."""
41
+ if self.wrapped_hooks and hasattr(self.wrapped_hooks, "on_handoff"):
42
+ await self.wrapped_hooks.on_handoff(context, from_agent, to_agent)
43
+
44
+ async def on_tool_start(self, context: RunContextWrapper, agent: Agent, tool: Tool) -> None:
45
+ """Check permission before tool execution."""
46
+ # Determine if this is an MCP tool
47
+ is_mcp = tool.name.startswith("mcp__") or hasattr(tool, "is_mcp")
48
+
49
+ # For now, we'll pass empty args since we can't easily access them from hooks
50
+ # The permission manager will still show the tool name for approval
51
+ tool_args = {}
52
+
53
+ # Check permission
54
+ if not self.permission_manager.check_permission(tool.name, tool_args, is_mcp):
55
+ raise ToolApprovalError(f"Tool execution denied: {tool.name}")
56
+
57
+ # Forward to wrapped hooks if available
58
+ if self.wrapped_hooks:
59
+ await self.wrapped_hooks.on_tool_start(context, agent, tool)
60
+
61
+ async def on_tool_end(
62
+ self, context: RunContextWrapper, agent: Agent, tool: Tool, result: str
63
+ ) -> None:
64
+ """Called after a tool is invoked."""
65
+ if self.wrapped_hooks:
66
+ await self.wrapped_hooks.on_tool_end(context, agent, tool, result)