koder 0.3.1__tar.gz → 0.3.3__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.
- {koder-0.3.1 → koder-0.3.3}/.claude/settings.local.json +5 -1
- koder-0.3.1/KODER.md → koder-0.3.3/AGENTS.md +4 -1
- koder-0.3.3/CLAUDE.md +1 -0
- {koder-0.3.1 → koder-0.3.3}/PKG-INFO +39 -28
- {koder-0.3.1 → koder-0.3.3}/README.md +25 -26
- {koder-0.3.1 → koder-0.3.3}/koder_agent/__init__.py +1 -1
- {koder-0.3.1 → koder-0.3.3}/koder_agent/agentic/__init__.py +1 -2
- {koder-0.3.1 → koder-0.3.3}/koder_agent/agentic/approval_hooks.py +4 -24
- {koder-0.3.1 → koder-0.3.3}/koder_agent/cli.py +91 -68
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/commands.py +56 -11
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/interactive.py +9 -19
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/scheduler.py +38 -31
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/streaming_display.py +373 -18
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/__init__.py +2 -2
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/engine.py +3 -14
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/search_ops.py +20 -2
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/todo_ops.py +10 -15
- koder-0.3.3/koder_agent/utils/client.py +55 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/utils/prompts.py +2 -2
- koder-0.3.3/koder_agent/utils/terminal_theme.py +201 -0
- {koder-0.3.1 → koder-0.3.3}/pyproject.toml +28 -14
- {koder-0.3.1 → koder-0.3.3}/uv.lock +1055 -639
- koder-0.3.1/.vscode/koder.json +0 -12
- koder-0.3.1/CLAUDE.md +0 -1
- koder-0.3.1/koder_agent/core/permissions.py +0 -300
- koder-0.3.1/koder_agent/utils/client.py +0 -82
- {koder-0.3.1 → koder-0.3.3}/.github/dependabot.yml +0 -0
- {koder-0.3.1 → koder-0.3.3}/.gitignore +0 -0
- {koder-0.3.1 → koder-0.3.3}/CONTRIBUTING.md +0 -0
- {koder-0.3.1 → koder-0.3.3}/LICENSE +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/agentic/agent.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/agentic/hooks.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/context.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/core/security.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/mcp/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/mcp/cli_handler.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/mcp/server_config.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/mcp/server_factory.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/mcp/server_manager.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/file_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/shell_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/task_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/tools/web_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/utils/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/utils/queue.py +0 -0
- {koder-0.3.1 → koder-0.3.3}/koder_agent/utils/sessions.py +0 -0
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"Bash(ruff check:*)",
|
|
12
12
|
"Bash(black:*)",
|
|
13
13
|
"WebFetch(domain:python-prompt-toolkit.readthedocs.io)",
|
|
14
|
-
"WebFetch(domain:docs.anthropic.com)"
|
|
14
|
+
"WebFetch(domain:docs.anthropic.com)",
|
|
15
|
+
"mcp__context7__resolve-library-id",
|
|
16
|
+
"mcp__context7__get-library-docs",
|
|
17
|
+
"Bash(timeout 15s uv run koder 'test permission ui')",
|
|
18
|
+
"Bash(timeout 15s uv run koder 'test permission ui one more time')"
|
|
15
19
|
],
|
|
16
20
|
"deny": []
|
|
17
21
|
}
|
|
@@ -10,6 +10,9 @@ This file provides guidance to KODER and Agentic AI when working with code in th
|
|
|
10
10
|
# Install dependencies
|
|
11
11
|
uv sync
|
|
12
12
|
|
|
13
|
+
# Upgrade dependencies
|
|
14
|
+
uv sync --upgrade
|
|
15
|
+
|
|
13
16
|
# Run the CLI in interactive mode
|
|
14
17
|
uv run koder
|
|
15
18
|
|
|
@@ -89,7 +92,7 @@ The project uses the `openai-agents` library with multi-provider support:
|
|
|
89
92
|
|
|
90
93
|
### Configuration
|
|
91
94
|
|
|
92
|
-
- **Context Loading**: The CLI looks for `
|
|
95
|
+
- **Context Loading**: The CLI looks for `AGENTS.md` in the working directory to load project-specific context
|
|
93
96
|
- **Database**: SQLite database at `~/.koder/koder.db` stores conversation history and MCP server configs
|
|
94
97
|
- **AI Provider Setup**: Set API credentials via environment variables (see README.md for provider-specific setup)
|
|
95
98
|
- **Model Selection**: Use `KODER_MODEL` environment variable to specify which model to use across providers
|
koder-0.3.3/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: koder
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
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
|
|
5
7
|
Author: Pengfei Ni
|
|
6
8
|
License-File: LICENSE
|
|
7
9
|
Keywords: agent,agentic,ai,copilot,litellm,openai,vibe coding
|
|
8
10
|
Requires-Python: >=3.9
|
|
9
11
|
Requires-Dist: aiosqlite>=0.19.0
|
|
12
|
+
Requires-Dist: apscheduler>=3.11.0
|
|
13
|
+
Requires-Dist: backoff>=2.2.1
|
|
10
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
|
|
11
18
|
Requires-Dist: google-cloud-aiplatform>=1.106.0
|
|
12
19
|
Requires-Dist: httpx[socks]>=0.25.0
|
|
13
20
|
Requires-Dist: openai-agents[litellm]>=0.2.4
|
|
14
21
|
Requires-Dist: openai==1.98.0
|
|
22
|
+
Requires-Dist: orjson>=3.11.2
|
|
15
23
|
Requires-Dist: prompt-toolkit>=3.0.51
|
|
16
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
|
|
17
28
|
Requires-Dist: requests>=2.31.0
|
|
18
|
-
Requires-Dist: rich>=
|
|
29
|
+
Requires-Dist: rich>=14.1.0
|
|
19
30
|
Requires-Dist: tiktoken>=0.5.0
|
|
31
|
+
Requires-Dist: websockets>=15.0.1
|
|
20
32
|
Description-Content-Type: text/markdown
|
|
21
33
|
|
|
22
34
|
# Koder
|
|
@@ -70,7 +82,7 @@ koder "create a Python function to calculate fibonacci numbers"
|
|
|
70
82
|
koder -s my-project "Help me implement a new feature"
|
|
71
83
|
|
|
72
84
|
# Use an explicit session flag
|
|
73
|
-
koder
|
|
85
|
+
koder -s my-project "Your prompt here"
|
|
74
86
|
```
|
|
75
87
|
|
|
76
88
|
## 🤖 Configuration
|
|
@@ -82,15 +94,21 @@ Koder automatically detects your AI provider based on available environment vari
|
|
|
82
94
|
```bash
|
|
83
95
|
# OpenAI models
|
|
84
96
|
export KODER_MODEL="gpt-4.1"
|
|
97
|
+
koder
|
|
85
98
|
|
|
86
99
|
# Claude models (via LiteLLM)
|
|
87
100
|
export KODER_MODEL="claude-opus-4-20250514"
|
|
101
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
102
|
+
koder
|
|
88
103
|
|
|
89
|
-
# Google models (via LiteLLM)
|
|
104
|
+
# Google Gemini models (via LiteLLM)
|
|
90
105
|
export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
106
|
+
export GOOGLE_API_KEY=your-api-key
|
|
107
|
+
koder
|
|
91
108
|
|
|
92
109
|
# Github Copilot (via LiteLLM)
|
|
93
110
|
export KODER_MODEL="github_copilot/claude-sonnet-4"
|
|
111
|
+
koder
|
|
94
112
|
```
|
|
95
113
|
|
|
96
114
|
### Supported Providers
|
|
@@ -106,6 +124,8 @@ export OPENAI_API_BASE=https://your-endpoint.com
|
|
|
106
124
|
|
|
107
125
|
# Optional: Specify model (default: gpt-4.1)
|
|
108
126
|
export KODER_MODEL="gpt-4o"
|
|
127
|
+
|
|
128
|
+
koder
|
|
109
129
|
```
|
|
110
130
|
|
|
111
131
|
</details>
|
|
@@ -114,20 +134,20 @@ export KODER_MODEL="gpt-4o"
|
|
|
114
134
|
<summary><b>Anthropic</b></summary>
|
|
115
135
|
|
|
116
136
|
```bash
|
|
117
|
-
export ANTHROPIC_API_KEY=your-api-key
|
|
118
137
|
export KODER_MODEL="claude-opus-4-20250514"
|
|
119
|
-
|
|
138
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
139
|
+
koder
|
|
120
140
|
```
|
|
121
141
|
|
|
122
142
|
</details>
|
|
123
143
|
|
|
124
144
|
<details>
|
|
125
|
-
<summary><b>Google
|
|
145
|
+
<summary><b>Google Gemini</b></summary>
|
|
126
146
|
|
|
127
147
|
```bash
|
|
128
|
-
export GOOGLE_API_KEY=your-api-key
|
|
129
|
-
# Optional: Specify model (default: gemini/gemini-2.5-pro)
|
|
130
148
|
export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
149
|
+
export GOOGLE_API_KEY=your-api-key
|
|
150
|
+
koder
|
|
131
151
|
```
|
|
132
152
|
|
|
133
153
|
</details>
|
|
@@ -137,6 +157,7 @@ export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
|
137
157
|
|
|
138
158
|
```bash
|
|
139
159
|
export KODER_MODEL="github_copilot/claude-sonnet-4"
|
|
160
|
+
koder
|
|
140
161
|
```
|
|
141
162
|
|
|
142
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.
|
|
@@ -147,25 +168,13 @@ On first run you will see a device code in the terminal. Visit <https://github.c
|
|
|
147
168
|
<summary><b>Azure OpenAI</b></summary>
|
|
148
169
|
|
|
149
170
|
```bash
|
|
150
|
-
|
|
151
|
-
export
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
export AZURE_OPENAI_DEPLOYMENT="my-gpt4o-deployment"
|
|
156
|
-
|
|
157
|
-
# Choose a model that maps to your deployment
|
|
158
|
-
export KODER_MODEL="gpt-4o"
|
|
159
|
-
|
|
160
|
-
# Optional: API version
|
|
161
|
-
export AZURE_OPENAI_API_VERSION="2025-04-01-preview"
|
|
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
|
|
162
176
|
```
|
|
163
177
|
|
|
164
|
-
Tips:
|
|
165
|
-
|
|
166
|
-
- Ensure the endpoint hostname matches your Azure resource.
|
|
167
|
-
- AZURE_OPENAI_DEPLOYMENT must match the deployed model name in Azure.
|
|
168
|
-
|
|
169
178
|
</details>
|
|
170
179
|
|
|
171
180
|
<details>
|
|
@@ -175,14 +184,16 @@ Tips:
|
|
|
175
184
|
|
|
176
185
|
```bash
|
|
177
186
|
# Google Vertex AI
|
|
187
|
+
export KODER_MODEL="vertex_ai/claude-sonnet-4@20250514"
|
|
178
188
|
export GOOGLE_APPLICATION_CREDENTIALS="your-sa-path.json"
|
|
179
189
|
export VERTEXAI_LOCATION="<your-region>"
|
|
180
|
-
|
|
190
|
+
koder
|
|
181
191
|
|
|
182
192
|
# Custom OpenAI-compatible endpoints
|
|
193
|
+
export KODER_MODEL="openai/<your-model-name>"
|
|
183
194
|
export OPENAI_API_KEY="your-key"
|
|
184
195
|
export OPENAI_BASE_URL="https://your-custom-endpoint.com/v1"
|
|
185
|
-
|
|
196
|
+
koder
|
|
186
197
|
```
|
|
187
198
|
|
|
188
199
|
</details>
|
|
@@ -49,7 +49,7 @@ koder "create a Python function to calculate fibonacci numbers"
|
|
|
49
49
|
koder -s my-project "Help me implement a new feature"
|
|
50
50
|
|
|
51
51
|
# Use an explicit session flag
|
|
52
|
-
koder
|
|
52
|
+
koder -s my-project "Your prompt here"
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## 🤖 Configuration
|
|
@@ -61,15 +61,21 @@ Koder automatically detects your AI provider based on available environment vari
|
|
|
61
61
|
```bash
|
|
62
62
|
# OpenAI models
|
|
63
63
|
export KODER_MODEL="gpt-4.1"
|
|
64
|
+
koder
|
|
64
65
|
|
|
65
66
|
# Claude models (via LiteLLM)
|
|
66
67
|
export KODER_MODEL="claude-opus-4-20250514"
|
|
68
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
69
|
+
koder
|
|
67
70
|
|
|
68
|
-
# Google models (via LiteLLM)
|
|
71
|
+
# Google Gemini models (via LiteLLM)
|
|
69
72
|
export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
73
|
+
export GOOGLE_API_KEY=your-api-key
|
|
74
|
+
koder
|
|
70
75
|
|
|
71
76
|
# Github Copilot (via LiteLLM)
|
|
72
77
|
export KODER_MODEL="github_copilot/claude-sonnet-4"
|
|
78
|
+
koder
|
|
73
79
|
```
|
|
74
80
|
|
|
75
81
|
### Supported Providers
|
|
@@ -85,6 +91,8 @@ export OPENAI_API_BASE=https://your-endpoint.com
|
|
|
85
91
|
|
|
86
92
|
# Optional: Specify model (default: gpt-4.1)
|
|
87
93
|
export KODER_MODEL="gpt-4o"
|
|
94
|
+
|
|
95
|
+
koder
|
|
88
96
|
```
|
|
89
97
|
|
|
90
98
|
</details>
|
|
@@ -93,20 +101,20 @@ export KODER_MODEL="gpt-4o"
|
|
|
93
101
|
<summary><b>Anthropic</b></summary>
|
|
94
102
|
|
|
95
103
|
```bash
|
|
96
|
-
export ANTHROPIC_API_KEY=your-api-key
|
|
97
104
|
export KODER_MODEL="claude-opus-4-20250514"
|
|
98
|
-
|
|
105
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
106
|
+
koder
|
|
99
107
|
```
|
|
100
108
|
|
|
101
109
|
</details>
|
|
102
110
|
|
|
103
111
|
<details>
|
|
104
|
-
<summary><b>Google
|
|
112
|
+
<summary><b>Google Gemini</b></summary>
|
|
105
113
|
|
|
106
114
|
```bash
|
|
107
|
-
export GOOGLE_API_KEY=your-api-key
|
|
108
|
-
# Optional: Specify model (default: gemini/gemini-2.5-pro)
|
|
109
115
|
export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
116
|
+
export GOOGLE_API_KEY=your-api-key
|
|
117
|
+
koder
|
|
110
118
|
```
|
|
111
119
|
|
|
112
120
|
</details>
|
|
@@ -116,6 +124,7 @@ export KODER_MODEL="gemini/gemini-2.5-pro"
|
|
|
116
124
|
|
|
117
125
|
```bash
|
|
118
126
|
export KODER_MODEL="github_copilot/claude-sonnet-4"
|
|
127
|
+
koder
|
|
119
128
|
```
|
|
120
129
|
|
|
121
130
|
On first run you will see a device code in the terminal. Visit <https://github.com/login/device> and enter the code to authenticate.
|
|
@@ -126,25 +135,13 @@ On first run you will see a device code in the terminal. Visit <https://github.c
|
|
|
126
135
|
<summary><b>Azure OpenAI</b></summary>
|
|
127
136
|
|
|
128
137
|
```bash
|
|
129
|
-
|
|
130
|
-
export
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
export AZURE_OPENAI_DEPLOYMENT="my-gpt4o-deployment"
|
|
135
|
-
|
|
136
|
-
# Choose a model that maps to your deployment
|
|
137
|
-
export KODER_MODEL="gpt-4o"
|
|
138
|
-
|
|
139
|
-
# Optional: API version
|
|
140
|
-
export AZURE_OPENAI_API_VERSION="2025-04-01-preview"
|
|
138
|
+
export KODER_MODEL=azure/gpt-5
|
|
139
|
+
export AZURE_API_KEY="your-azure-api-key"
|
|
140
|
+
export ZURE_API_BASE="https://your-resource.openai.azure.com"
|
|
141
|
+
export AZURE_API_VERSION="2025-04-01-preview"
|
|
142
|
+
koder
|
|
141
143
|
```
|
|
142
144
|
|
|
143
|
-
Tips:
|
|
144
|
-
|
|
145
|
-
- Ensure the endpoint hostname matches your Azure resource.
|
|
146
|
-
- AZURE_OPENAI_DEPLOYMENT must match the deployed model name in Azure.
|
|
147
|
-
|
|
148
145
|
</details>
|
|
149
146
|
|
|
150
147
|
<details>
|
|
@@ -154,14 +151,16 @@ Tips:
|
|
|
154
151
|
|
|
155
152
|
```bash
|
|
156
153
|
# Google Vertex AI
|
|
154
|
+
export KODER_MODEL="vertex_ai/claude-sonnet-4@20250514"
|
|
157
155
|
export GOOGLE_APPLICATION_CREDENTIALS="your-sa-path.json"
|
|
158
156
|
export VERTEXAI_LOCATION="<your-region>"
|
|
159
|
-
|
|
157
|
+
koder
|
|
160
158
|
|
|
161
159
|
# Custom OpenAI-compatible endpoints
|
|
160
|
+
export KODER_MODEL="openai/<your-model-name>"
|
|
162
161
|
export OPENAI_API_KEY="your-key"
|
|
163
162
|
export OPENAI_BASE_URL="https://your-custom-endpoint.com/v1"
|
|
164
|
-
|
|
163
|
+
koder
|
|
165
164
|
```
|
|
166
165
|
|
|
167
166
|
</details>
|
|
@@ -5,14 +5,13 @@ from .agent import (
|
|
|
5
5
|
# create_planner_agent,
|
|
6
6
|
get_model_name,
|
|
7
7
|
)
|
|
8
|
-
from .approval_hooks import ApprovalHooks
|
|
8
|
+
from .approval_hooks import ApprovalHooks
|
|
9
9
|
from .hooks import ToolDisplayHooks, get_display_hooks
|
|
10
10
|
|
|
11
11
|
__all__ = [
|
|
12
12
|
"ToolDisplayHooks",
|
|
13
13
|
"get_display_hooks",
|
|
14
14
|
"ApprovalHooks",
|
|
15
|
-
"ToolApprovalError",
|
|
16
15
|
# "create_planner_agent",
|
|
17
16
|
"create_dev_agent",
|
|
18
17
|
"get_model_name",
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Simple hooks for tool execution without permission checks."""
|
|
2
2
|
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
5
|
from agents import Agent, RunContextWrapper, RunHooks, Tool
|
|
6
6
|
|
|
7
|
-
from ..core.permissions import PermissionManager
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ToolApprovalError(Exception):
|
|
11
|
-
"""Raised when tool execution is denied."""
|
|
12
|
-
|
|
13
7
|
|
|
14
8
|
class ApprovalHooks(RunHooks):
|
|
15
|
-
"""RunHooks implementation that
|
|
9
|
+
"""RunHooks implementation that simply forwards to wrapped hooks without permission checks."""
|
|
16
10
|
|
|
17
|
-
def __init__(self,
|
|
11
|
+
def __init__(self, wrapped_hooks: RunHooks):
|
|
18
12
|
"""Initialize approval hooks.
|
|
19
13
|
|
|
20
14
|
Args:
|
|
21
|
-
permission_manager: Permission manager instance
|
|
22
15
|
wrapped_hooks: Optional hooks to wrap (e.g., display hooks)
|
|
23
16
|
"""
|
|
24
|
-
self.permission_manager = permission_manager
|
|
25
17
|
self.wrapped_hooks = wrapped_hooks
|
|
26
18
|
|
|
27
19
|
async def on_agent_start(self, context: RunContextWrapper, agent: Agent) -> None:
|
|
@@ -42,19 +34,7 @@ class ApprovalHooks(RunHooks):
|
|
|
42
34
|
await self.wrapped_hooks.on_handoff(context, from_agent, to_agent)
|
|
43
35
|
|
|
44
36
|
async def on_tool_start(self, context: RunContextWrapper, agent: Agent, tool: Tool) -> None:
|
|
45
|
-
"""
|
|
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
|
|
37
|
+
"""Forward to wrapped hooks for tool display."""
|
|
58
38
|
if self.wrapped_hooks:
|
|
59
39
|
await self.wrapped_hooks.on_tool_start(context, agent, tool)
|
|
60
40
|
|
|
@@ -7,7 +7,6 @@ import sys
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from typing import Optional
|
|
9
9
|
|
|
10
|
-
from rich.console import Console
|
|
11
10
|
from rich.panel import Panel
|
|
12
11
|
|
|
13
12
|
from .core.commands import slash_handler
|
|
@@ -15,8 +14,9 @@ from .core.context import ContextManager
|
|
|
15
14
|
from .core.interactive import InteractivePrompt
|
|
16
15
|
from .core.scheduler import AgentScheduler
|
|
17
16
|
from .utils import default_session_local_ms, picker_arrows, setup_openai_client, sort_sessions_desc
|
|
17
|
+
from .utils.terminal_theme import get_adaptive_console
|
|
18
18
|
|
|
19
|
-
console =
|
|
19
|
+
console = get_adaptive_console()
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
async def _prompt_select_session() -> Optional[str]:
|
|
@@ -32,86 +32,90 @@ async def _prompt_select_session() -> Optional[str]:
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
async def load_context() -> str:
|
|
35
|
+
"""Load context information from the project directory.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
str: The loaded context information.
|
|
39
|
+
"""
|
|
35
40
|
context_info = []
|
|
36
41
|
current_dir = os.getcwd()
|
|
37
42
|
context_info.append(f"Working directory: {current_dir}")
|
|
38
|
-
koder_md_path = Path(current_dir) / "
|
|
43
|
+
koder_md_path = Path(current_dir) / "AGENTS.md"
|
|
39
44
|
if koder_md_path.exists():
|
|
40
45
|
try:
|
|
41
46
|
koder_content = koder_md_path.read_text("utf-8", errors="ignore")
|
|
42
|
-
context_info.append(f"
|
|
47
|
+
context_info.append(f"AGENTS.md content:\n{koder_content}")
|
|
43
48
|
except Exception as e:
|
|
44
|
-
context_info.append(f"Error reading
|
|
49
|
+
context_info.append(f"Error reading AGENTS.md: {e}")
|
|
45
50
|
return "\n\n".join(context_info)
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
async def main():
|
|
54
|
+
"""Run the Koder CLI.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
int: The exit code.
|
|
58
|
+
"""
|
|
49
59
|
try:
|
|
50
60
|
setup_openai_client()
|
|
51
61
|
except ValueError as e:
|
|
52
62
|
console.print(Panel(f"[red]{e}[/red]", title="❌ Error", border_style="red"))
|
|
53
63
|
return 1
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
mcp_parser = subparsers.add_parser("mcp", help="Manage MCP servers")
|
|
65
|
-
mcp_subparsers = mcp_parser.add_subparsers(dest="mcp_action", help="MCP actions")
|
|
66
|
-
|
|
67
|
-
add_parser = mcp_subparsers.add_parser("add", help="Add an MCP server")
|
|
68
|
-
add_parser.add_argument("name", help="Server name")
|
|
69
|
-
add_parser.add_argument("command_or_url", help="Command for stdio or URL for SSE/HTTP")
|
|
70
|
-
add_parser.add_argument("args", nargs="*", help="Arguments for stdio command")
|
|
71
|
-
add_parser.add_argument(
|
|
72
|
-
"--transport", choices=["stdio", "sse", "http"], default="stdio", help="Transport type"
|
|
73
|
-
)
|
|
74
|
-
add_parser.add_argument(
|
|
75
|
-
"-e", "--env", action="append", help="Environment variables (KEY=VALUE)"
|
|
76
|
-
)
|
|
77
|
-
add_parser.add_argument("--header", action="append", help="HTTP headers (Key: Value)")
|
|
78
|
-
add_parser.add_argument("--cache-tools", action="store_true", help="Cache tools list")
|
|
79
|
-
add_parser.add_argument("--allow-tool", action="append", help="Allowed tools")
|
|
80
|
-
add_parser.add_argument("--block-tool", action="append", help="Blocked tools")
|
|
81
|
-
|
|
82
|
-
mcp_subparsers.add_parser("list", help="List all MCP servers")
|
|
83
|
-
|
|
84
|
-
get_parser = mcp_subparsers.add_parser("get", help="Get details for a specific server")
|
|
85
|
-
get_parser.add_argument("name", help="Server name")
|
|
86
|
-
|
|
87
|
-
remove_parser = mcp_subparsers.add_parser("remove", help="Remove an MCP server")
|
|
88
|
-
remove_parser.add_argument("name", help="Server name")
|
|
65
|
+
# Check if first argument is "mcp" to decide parser strategy
|
|
66
|
+
if len(sys.argv) > 1 and sys.argv[1] == "mcp":
|
|
67
|
+
# Use subcommand parser
|
|
68
|
+
parser = argparse.ArgumentParser(description="Koder - AI Coding Assistant")
|
|
69
|
+
parser.add_argument("--session", "-s", default=None, help="Session ID for context")
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
"--resume", action="store_true", help="List and select a previous session to resume"
|
|
72
|
+
)
|
|
73
|
+
parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
|
|
89
74
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
75
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
76
|
+
|
|
77
|
+
mcp_parser = subparsers.add_parser("mcp", help="Manage MCP servers")
|
|
78
|
+
mcp_subparsers = mcp_parser.add_subparsers(dest="mcp_action", help="MCP actions")
|
|
79
|
+
|
|
80
|
+
add_parser = mcp_subparsers.add_parser("add", help="Add an MCP server")
|
|
81
|
+
add_parser.add_argument("name", help="Server name")
|
|
82
|
+
add_parser.add_argument("command_or_url", help="Command for stdio or URL for SSE/HTTP")
|
|
83
|
+
add_parser.add_argument("args", nargs="*", help="Arguments for stdio command")
|
|
84
|
+
add_parser.add_argument(
|
|
85
|
+
"--transport", choices=["stdio", "sse", "http"], default="stdio", help="Transport type"
|
|
86
|
+
)
|
|
87
|
+
add_parser.add_argument(
|
|
88
|
+
"-e", "--env", action="append", help="Environment variables (KEY=VALUE)"
|
|
89
|
+
)
|
|
90
|
+
add_parser.add_argument("--header", action="append", help="HTTP headers (Key: Value)")
|
|
91
|
+
add_parser.add_argument("--cache-tools", action="store_true", help="Cache tools list")
|
|
92
|
+
add_parser.add_argument("--allow-tool", action="append", help="Allowed tools")
|
|
93
|
+
add_parser.add_argument("--block-tool", action="append", help="Blocked tools")
|
|
94
|
+
|
|
95
|
+
mcp_subparsers.add_parser("list", help="List all MCP servers")
|
|
96
|
+
|
|
97
|
+
get_parser = mcp_subparsers.add_parser("get", help="Get details for a specific server")
|
|
98
|
+
get_parser.add_argument("name", help="Server name")
|
|
99
|
+
|
|
100
|
+
remove_parser = mcp_subparsers.add_parser("remove", help="Remove an MCP server")
|
|
101
|
+
remove_parser.add_argument("name", help="Server name")
|
|
102
|
+
else:
|
|
103
|
+
# Use simple parser for prompt mode
|
|
104
|
+
parser = argparse.ArgumentParser(description="Koder - AI Coding Assistant")
|
|
105
|
+
parser.add_argument("--session", "-s", default=None, help="Session ID for context")
|
|
106
|
+
parser.add_argument(
|
|
107
|
+
"--resume", action="store_true", help="List and select a previous session to resume"
|
|
108
|
+
)
|
|
109
|
+
parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
|
|
110
|
+
parser.add_argument(
|
|
111
|
+
"prompt", nargs="*", help="Prompt text (if not provided, starts interactive mode)"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
args = parser.parse_args()
|
|
115
|
+
|
|
116
|
+
# Set command to None for prompt mode
|
|
117
|
+
if not hasattr(args, "command"):
|
|
118
|
+
args.command = None
|
|
115
119
|
|
|
116
120
|
if getattr(args, "resume", False):
|
|
117
121
|
selected = await _prompt_select_session()
|
|
@@ -142,11 +146,29 @@ async def main():
|
|
|
142
146
|
interactive_prompt = InteractivePrompt(commands_dict)
|
|
143
147
|
|
|
144
148
|
prompt_text = getattr(args, "prompt", None)
|
|
145
|
-
if prompt_text:
|
|
149
|
+
if prompt_text and len(prompt_text) > 0:
|
|
146
150
|
prompt = " ".join(prompt_text)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
|
|
152
|
+
# Check if this is a slash command
|
|
153
|
+
if slash_handler.is_slash_command(prompt):
|
|
154
|
+
slash_response = await slash_handler.handle_slash_input(prompt, scheduler)
|
|
155
|
+
if slash_response:
|
|
156
|
+
# Handle special session switch response
|
|
157
|
+
if slash_response.startswith("session_switch:"):
|
|
158
|
+
new_session_id = slash_response.split(":", 1)[1]
|
|
159
|
+
console.print(f"[dim]Switched to session: {new_session_id}[/dim]")
|
|
160
|
+
else:
|
|
161
|
+
console.print(
|
|
162
|
+
Panel(
|
|
163
|
+
f"[bold green]{slash_response}[/bold green]",
|
|
164
|
+
title="⚡ Command Response",
|
|
165
|
+
border_style="green",
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
if context:
|
|
170
|
+
prompt = f"Context:\n{context}\n\nUser request: {prompt}"
|
|
171
|
+
await scheduler.handle(prompt)
|
|
150
172
|
else:
|
|
151
173
|
while True:
|
|
152
174
|
try:
|
|
@@ -205,6 +227,7 @@ async def main():
|
|
|
205
227
|
|
|
206
228
|
|
|
207
229
|
def run():
|
|
230
|
+
"""Run the Koder CLI."""
|
|
208
231
|
try:
|
|
209
232
|
exit_code = asyncio.run(main())
|
|
210
233
|
exit(exit_code)
|