koder 0.3.1__tar.gz → 0.3.2__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.2}/.claude/settings.local.json +3 -1
- koder-0.3.2/.vscode/koder.json +10 -0
- {koder-0.3.1 → koder-0.3.2}/KODER.md +3 -0
- {koder-0.3.1 → koder-0.3.2}/PKG-INFO +39 -28
- {koder-0.3.1 → koder-0.3.2}/README.md +25 -26
- {koder-0.3.1 → koder-0.3.2}/koder_agent/__init__.py +1 -1
- {koder-0.3.1 → koder-0.3.2}/koder_agent/cli.py +75 -63
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/commands.py +46 -1
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/interactive.py +4 -4
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/scheduler.py +16 -11
- koder-0.3.2/koder_agent/utils/client.py +55 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/utils/prompts.py +1 -1
- {koder-0.3.1 → koder-0.3.2}/pyproject.toml +28 -14
- {koder-0.3.1 → koder-0.3.2}/uv.lock +1055 -639
- koder-0.3.1/.vscode/koder.json +0 -12
- koder-0.3.1/koder_agent/utils/client.py +0 -82
- {koder-0.3.1 → koder-0.3.2}/.github/dependabot.yml +0 -0
- {koder-0.3.1 → koder-0.3.2}/.gitignore +0 -0
- {koder-0.3.1 → koder-0.3.2}/CLAUDE.md +0 -0
- {koder-0.3.1 → koder-0.3.2}/CONTRIBUTING.md +0 -0
- {koder-0.3.1 → koder-0.3.2}/LICENSE +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/agentic/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/agentic/agent.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/agentic/approval_hooks.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/agentic/hooks.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/context.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/permissions.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/security.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/core/streaming_display.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/mcp/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/mcp/cli_handler.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/mcp/server_config.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/mcp/server_factory.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/mcp/server_manager.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/engine.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/file_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/search_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/shell_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/task_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/todo_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/tools/web_ops.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/utils/__init__.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/utils/queue.py +0 -0
- {koder-0.3.1 → koder-0.3.2}/koder_agent/utils/sessions.py +0 -0
|
@@ -11,7 +11,9 @@
|
|
|
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"
|
|
15
17
|
],
|
|
16
18
|
"deny": []
|
|
17
19
|
}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: koder
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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>
|
|
@@ -52,66 +52,60 @@ async def main():
|
|
|
52
52
|
console.print(Panel(f"[red]{e}[/red]", title="❌ Error", border_style="red"))
|
|
53
53
|
return 1
|
|
54
54
|
|
|
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")
|
|
55
|
+
# Check if first argument is "mcp" to decide parser strategy
|
|
56
|
+
if len(sys.argv) > 1 and sys.argv[1] == "mcp":
|
|
57
|
+
# Use subcommand parser
|
|
58
|
+
parser = argparse.ArgumentParser(description="Koder - AI Coding Assistant")
|
|
59
|
+
parser.add_argument("--session", "-s", default=None, help="Session ID for context")
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"--resume", action="store_true", help="List and select a previous session to resume"
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
|
|
89
64
|
|
|
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
|
-
|
|
65
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
66
|
+
|
|
67
|
+
mcp_parser = subparsers.add_parser("mcp", help="Manage MCP servers")
|
|
68
|
+
mcp_subparsers = mcp_parser.add_subparsers(dest="mcp_action", help="MCP actions")
|
|
69
|
+
|
|
70
|
+
add_parser = mcp_subparsers.add_parser("add", help="Add an MCP server")
|
|
71
|
+
add_parser.add_argument("name", help="Server name")
|
|
72
|
+
add_parser.add_argument("command_or_url", help="Command for stdio or URL for SSE/HTTP")
|
|
73
|
+
add_parser.add_argument("args", nargs="*", help="Arguments for stdio command")
|
|
74
|
+
add_parser.add_argument(
|
|
75
|
+
"--transport", choices=["stdio", "sse", "http"], default="stdio", help="Transport type"
|
|
76
|
+
)
|
|
77
|
+
add_parser.add_argument(
|
|
78
|
+
"-e", "--env", action="append", help="Environment variables (KEY=VALUE)"
|
|
79
|
+
)
|
|
80
|
+
add_parser.add_argument("--header", action="append", help="HTTP headers (Key: Value)")
|
|
81
|
+
add_parser.add_argument("--cache-tools", action="store_true", help="Cache tools list")
|
|
82
|
+
add_parser.add_argument("--allow-tool", action="append", help="Allowed tools")
|
|
83
|
+
add_parser.add_argument("--block-tool", action="append", help="Blocked tools")
|
|
84
|
+
|
|
85
|
+
mcp_subparsers.add_parser("list", help="List all MCP servers")
|
|
86
|
+
|
|
87
|
+
get_parser = mcp_subparsers.add_parser("get", help="Get details for a specific server")
|
|
88
|
+
get_parser.add_argument("name", help="Server name")
|
|
89
|
+
|
|
90
|
+
remove_parser = mcp_subparsers.add_parser("remove", help="Remove an MCP server")
|
|
91
|
+
remove_parser.add_argument("name", help="Server name")
|
|
92
|
+
else:
|
|
93
|
+
# Use simple parser for prompt mode
|
|
94
|
+
parser = argparse.ArgumentParser(description="Koder - AI Coding Assistant")
|
|
95
|
+
parser.add_argument("--session", "-s", default=None, help="Session ID for context")
|
|
96
|
+
parser.add_argument(
|
|
97
|
+
"--resume", action="store_true", help="List and select a previous session to resume"
|
|
98
|
+
)
|
|
99
|
+
parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
|
|
100
|
+
parser.add_argument(
|
|
101
|
+
"prompt", nargs="*", help="Prompt text (if not provided, starts interactive mode)"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
args = parser.parse_args()
|
|
105
|
+
|
|
106
|
+
# Set command to None for prompt mode
|
|
107
|
+
if not hasattr(args, "command"):
|
|
108
|
+
args.command = None
|
|
115
109
|
|
|
116
110
|
if getattr(args, "resume", False):
|
|
117
111
|
selected = await _prompt_select_session()
|
|
@@ -142,11 +136,29 @@ async def main():
|
|
|
142
136
|
interactive_prompt = InteractivePrompt(commands_dict)
|
|
143
137
|
|
|
144
138
|
prompt_text = getattr(args, "prompt", None)
|
|
145
|
-
if prompt_text:
|
|
139
|
+
if prompt_text and len(prompt_text) > 0:
|
|
146
140
|
prompt = " ".join(prompt_text)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
|
|
142
|
+
# Check if this is a slash command
|
|
143
|
+
if slash_handler.is_slash_command(prompt):
|
|
144
|
+
slash_response = await slash_handler.handle_slash_input(prompt, scheduler)
|
|
145
|
+
if slash_response:
|
|
146
|
+
# Handle special session switch response
|
|
147
|
+
if slash_response.startswith("session_switch:"):
|
|
148
|
+
new_session_id = slash_response.split(":", 1)[1]
|
|
149
|
+
console.print(f"[dim]Switched to session: {new_session_id}[/dim]")
|
|
150
|
+
else:
|
|
151
|
+
console.print(
|
|
152
|
+
Panel(
|
|
153
|
+
f"[bold green]{slash_response}[/bold green]",
|
|
154
|
+
title="⚡ Command Response",
|
|
155
|
+
border_style="green",
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
else:
|
|
159
|
+
if context:
|
|
160
|
+
prompt = f"Context:\n{context}\n\nUser request: {prompt}"
|
|
161
|
+
await scheduler.handle(prompt)
|
|
150
162
|
else:
|
|
151
163
|
while True:
|
|
152
164
|
try:
|
|
@@ -117,7 +117,6 @@ class StatusCommand(SlashCommand):
|
|
|
117
117
|
table.add_row("Total Sessions", str(len(sessions)))
|
|
118
118
|
table.add_row("Working Directory", os.getcwd())
|
|
119
119
|
|
|
120
|
-
|
|
121
120
|
if sessions:
|
|
122
121
|
table.add_section()
|
|
123
122
|
table.add_row("[bold]Available Sessions[/bold]", "[bold]ID[/bold]")
|
|
@@ -174,11 +173,57 @@ class McpCommand(SlashCommand):
|
|
|
174
173
|
return f"Error listing MCP servers: {e}"
|
|
175
174
|
|
|
176
175
|
|
|
176
|
+
class HelpCommand(SlashCommand):
|
|
177
|
+
"""Show help and usage instructions."""
|
|
178
|
+
|
|
179
|
+
def __init__(self):
|
|
180
|
+
super().__init__("help", "Show help and usage instructions")
|
|
181
|
+
|
|
182
|
+
async def execute(self, scheduler, *_args) -> str:
|
|
183
|
+
"""Execute the /help command."""
|
|
184
|
+
# Show general usage instructions
|
|
185
|
+
usage_text = """[bold cyan]Koder - AI Coding Assistant[/bold cyan]
|
|
186
|
+
|
|
187
|
+
[bold]How to use:[/bold]
|
|
188
|
+
• Type your coding questions or requests in natural language
|
|
189
|
+
• Use slash commands (/) for special functions
|
|
190
|
+
• Press Ctrl+C to exit interactive mode
|
|
191
|
+
• Type 'exit' or 'quit' to end the session
|
|
192
|
+
|
|
193
|
+
[bold]Examples:[/bold]
|
|
194
|
+
• "Help me implement a login feature"
|
|
195
|
+
• "Fix the bug in auth.py"
|
|
196
|
+
• "Explain this code"
|
|
197
|
+
• "/status" - show current configuration
|
|
198
|
+
• "/clear" - start a new session"""
|
|
199
|
+
|
|
200
|
+
console.print(Panel(usage_text, title="📖 Help", border_style="cyan"))
|
|
201
|
+
|
|
202
|
+
# Get the command handler to access all commands
|
|
203
|
+
handler = scheduler.slash_handler if hasattr(scheduler, "slash_handler") else slash_handler
|
|
204
|
+
commands = handler.get_command_list()
|
|
205
|
+
|
|
206
|
+
if commands:
|
|
207
|
+
# Show available slash commands in a table
|
|
208
|
+
table = Table(show_header=True, header_style="bold cyan", box=None)
|
|
209
|
+
table.add_column("Command", style="cyan", width=12)
|
|
210
|
+
table.add_column("Description", style="white")
|
|
211
|
+
|
|
212
|
+
for name, description in commands:
|
|
213
|
+
table.add_row(f"/{name}", description)
|
|
214
|
+
|
|
215
|
+
console.print()
|
|
216
|
+
console.print(table)
|
|
217
|
+
|
|
218
|
+
return ""
|
|
219
|
+
|
|
220
|
+
|
|
177
221
|
class SlashCommandHandler:
|
|
178
222
|
"""Handles slash command detection and execution."""
|
|
179
223
|
|
|
180
224
|
def __init__(self):
|
|
181
225
|
self.commands: Dict[str, SlashCommand] = {
|
|
226
|
+
"help": HelpCommand(),
|
|
182
227
|
"init": InitCommand(),
|
|
183
228
|
"clear": ClearCommand(),
|
|
184
229
|
"status": StatusCommand(),
|
|
@@ -92,10 +92,10 @@ class InteractivePrompt:
|
|
|
92
92
|
self.session = PromptSession(
|
|
93
93
|
completer=self.completer,
|
|
94
94
|
complete_while_typing=True,
|
|
95
|
-
mouse_support=
|
|
95
|
+
mouse_support=False,
|
|
96
96
|
)
|
|
97
97
|
|
|
98
|
-
async def get_input(self, prompt_text: str = "
|
|
98
|
+
async def get_input(self, prompt_text: str = "User") -> str:
|
|
99
99
|
"""Get user input with Rich panel display and prompt_toolkit completion."""
|
|
100
100
|
# Create buffer
|
|
101
101
|
buffer = Buffer(
|
|
@@ -120,7 +120,7 @@ class InteractivePrompt:
|
|
|
120
120
|
# Create simple frame without heavy styling
|
|
121
121
|
framed_input = Frame(
|
|
122
122
|
body=input_window,
|
|
123
|
-
title=f"{prompt_text}",
|
|
123
|
+
title=f"{prompt_text} (Ctrl+C to exit)",
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
# Key bindings
|
|
@@ -224,7 +224,7 @@ class InteractivePrompt:
|
|
|
224
224
|
key_bindings=kb,
|
|
225
225
|
style=style,
|
|
226
226
|
full_screen=False,
|
|
227
|
-
mouse_support=
|
|
227
|
+
mouse_support=False, # Disable mouse support to allow terminal scrolling
|
|
228
228
|
)
|
|
229
229
|
|
|
230
230
|
result = await app.run_async()
|
|
@@ -156,10 +156,8 @@ class AgentScheduler:
|
|
|
156
156
|
# Add space before streaming starts
|
|
157
157
|
print()
|
|
158
158
|
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
sys.stdout.write("\033[6n") # Request cursor position
|
|
162
|
-
sys.stdout.flush()
|
|
159
|
+
# Skip cursor position capture - it causes escape sequence leaks
|
|
160
|
+
# The terminal clearing strategies below work without explicit position tracking
|
|
163
161
|
|
|
164
162
|
# Run the agent in streaming mode
|
|
165
163
|
if self.dev_agent is None:
|
|
@@ -181,9 +179,9 @@ class AgentScheduler:
|
|
|
181
179
|
with Live(
|
|
182
180
|
"",
|
|
183
181
|
console=console,
|
|
184
|
-
refresh_per_second=8,
|
|
185
|
-
transient=
|
|
186
|
-
vertical_overflow="
|
|
182
|
+
refresh_per_second=8,
|
|
183
|
+
transient=True,
|
|
184
|
+
vertical_overflow="crop",
|
|
187
185
|
) as live:
|
|
188
186
|
try:
|
|
189
187
|
# Process streaming events
|
|
@@ -313,10 +311,17 @@ class AgentScheduler:
|
|
|
313
311
|
except Exception:
|
|
314
312
|
pass # Fallback to simple approach
|
|
315
313
|
|
|
316
|
-
# Strategy 2:
|
|
317
|
-
#
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
# Strategy 2: Always show final text response, but avoid duplicate tool output
|
|
315
|
+
# Get the final text response separately to ensure it's always displayed
|
|
316
|
+
final_text_response = display_manager.get_final_text()
|
|
317
|
+
|
|
318
|
+
if final_text_response and final_text_response.strip():
|
|
319
|
+
# Always show the final AI text response
|
|
320
|
+
print() # Add spacing
|
|
321
|
+
console.print(final_text_response)
|
|
322
|
+
print() # Add spacing after
|
|
323
|
+
elif not content_displayed:
|
|
324
|
+
# Fallback: show full content if no separate text and nothing was displayed
|
|
320
325
|
print() # Add spacing
|
|
321
326
|
console.print(final_content)
|
|
322
327
|
print() # Add spacing after
|