koder 0.3.2__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.2 → koder-0.3.3}/.claude/settings.local.json +3 -1
- koder-0.3.2/KODER.md → koder-0.3.3/AGENTS.md +1 -1
- koder-0.3.3/CLAUDE.md +1 -0
- {koder-0.3.2 → koder-0.3.3}/PKG-INFO +1 -1
- {koder-0.3.2 → koder-0.3.3}/koder_agent/agentic/__init__.py +1 -2
- {koder-0.3.2 → koder-0.3.3}/koder_agent/agentic/approval_hooks.py +4 -24
- {koder-0.3.2 → koder-0.3.3}/koder_agent/cli.py +16 -5
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/commands.py +10 -10
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/interactive.py +5 -15
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/scheduler.py +26 -24
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/streaming_display.py +373 -18
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/__init__.py +2 -2
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/engine.py +3 -14
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/search_ops.py +20 -2
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/todo_ops.py +10 -15
- {koder-0.3.2 → koder-0.3.3}/koder_agent/utils/prompts.py +1 -1
- koder-0.3.3/koder_agent/utils/terminal_theme.py +201 -0
- {koder-0.3.2 → koder-0.3.3}/pyproject.toml +1 -1
- koder-0.3.2/.vscode/koder.json +0 -10
- koder-0.3.2/CLAUDE.md +0 -1
- koder-0.3.2/koder_agent/core/permissions.py +0 -300
- {koder-0.3.2 → koder-0.3.3}/.github/dependabot.yml +0 -0
- {koder-0.3.2 → koder-0.3.3}/.gitignore +0 -0
- {koder-0.3.2 → koder-0.3.3}/CONTRIBUTING.md +0 -0
- {koder-0.3.2 → koder-0.3.3}/LICENSE +0 -0
- {koder-0.3.2 → koder-0.3.3}/README.md +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/__init__.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/agentic/agent.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/agentic/hooks.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/__init__.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/context.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/core/security.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/mcp/__init__.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/mcp/cli_handler.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/mcp/server_config.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/mcp/server_factory.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/mcp/server_manager.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/file_ops.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/shell_ops.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/task_ops.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/tools/web_ops.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/utils/__init__.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/utils/client.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/utils/queue.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/koder_agent/utils/sessions.py +0 -0
- {koder-0.3.2 → koder-0.3.3}/uv.lock +0 -0
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"WebFetch(domain:python-prompt-toolkit.readthedocs.io)",
|
|
14
14
|
"WebFetch(domain:docs.anthropic.com)",
|
|
15
15
|
"mcp__context7__resolve-library-id",
|
|
16
|
-
"mcp__context7__get-library-docs"
|
|
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')"
|
|
17
19
|
],
|
|
18
20
|
"deny": []
|
|
19
21
|
}
|
|
@@ -92,7 +92,7 @@ The project uses the `openai-agents` library with multi-provider support:
|
|
|
92
92
|
|
|
93
93
|
### Configuration
|
|
94
94
|
|
|
95
|
-
- **Context Loading**: The CLI looks for `
|
|
95
|
+
- **Context Loading**: The CLI looks for `AGENTS.md` in the working directory to load project-specific context
|
|
96
96
|
- **Database**: SQLite database at `~/.koder/koder.db` stores conversation history and MCP server configs
|
|
97
97
|
- **AI Provider Setup**: Set API credentials via environment variables (see README.md for provider-specific setup)
|
|
98
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,6 +1,6 @@
|
|
|
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
5
|
Project-URL: Homepage, https://github.com/feiskyer/koder
|
|
6
6
|
Project-URL: Repository, https://github.com/feiskyer/koder
|
|
@@ -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,20 +32,30 @@ 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:
|
|
@@ -217,6 +227,7 @@ async def main():
|
|
|
217
227
|
|
|
218
228
|
|
|
219
229
|
def run():
|
|
230
|
+
"""Run the Koder CLI."""
|
|
220
231
|
try:
|
|
221
232
|
exit_code = asyncio.run(main())
|
|
222
233
|
exit(exit_code)
|
|
@@ -27,36 +27,36 @@ class SlashCommand:
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class InitCommand(SlashCommand):
|
|
30
|
-
"""Initialize project by reading codebase and generating
|
|
30
|
+
"""Initialize project by reading codebase and generating AGENTS.md."""
|
|
31
31
|
|
|
32
32
|
def __init__(self):
|
|
33
|
-
super().__init__("init", "Read through the project and generate
|
|
33
|
+
super().__init__("init", "Read through the project and generate AGENTS.md")
|
|
34
34
|
|
|
35
35
|
async def execute(self, scheduler, *_args) -> str:
|
|
36
36
|
"""Execute the /init command."""
|
|
37
|
-
koder_md_path = Path(os.getcwd()) / "
|
|
37
|
+
koder_md_path = Path(os.getcwd()) / "AGENTS.md"
|
|
38
38
|
if koder_md_path.exists():
|
|
39
|
-
console.print("[yellow]⚠️
|
|
40
|
-
return "⚠️
|
|
39
|
+
console.print("[yellow]⚠️ AGENTS.md already exists.[/yellow]")
|
|
40
|
+
return "⚠️ AGENTS.md already exists."
|
|
41
41
|
|
|
42
|
-
# Use the agent to analyze the project and generate
|
|
43
|
-
prompt = """Please analyze this codebase and create a
|
|
42
|
+
# Use the agent to analyze the project and generate AGENTS.md
|
|
43
|
+
prompt = """Please analyze this codebase and create a AGENTS.md file containing:
|
|
44
44
|
1. Build/lint/test commands - especially for running a single test
|
|
45
45
|
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
|
|
46
46
|
|
|
47
47
|
Usage notes:
|
|
48
48
|
- The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.\
|
|
49
|
-
- If there's already a
|
|
49
|
+
- If there's already a AGENTS.md, improve it.\
|
|
50
50
|
- If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them.\
|
|
51
51
|
- Be sure to prefix the file with the following text:
|
|
52
52
|
|
|
53
|
-
#
|
|
53
|
+
# AGENTS.md
|
|
54
54
|
|
|
55
55
|
This file provides guidance to Koder when working with code in this repository.
|
|
56
56
|
"""
|
|
57
57
|
|
|
58
58
|
await scheduler.handle(prompt)
|
|
59
|
-
return "✅
|
|
59
|
+
return "✅ AGENTS.md generated."
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
class ClearCommand(SlashCommand):
|
|
@@ -14,11 +14,11 @@ from prompt_toolkit.layout.dimension import Dimension
|
|
|
14
14
|
from prompt_toolkit.layout.menus import CompletionsMenu
|
|
15
15
|
from prompt_toolkit.layout.processors import BeforeInput
|
|
16
16
|
from prompt_toolkit.shortcuts import PromptSession, confirm
|
|
17
|
-
from prompt_toolkit.styles import Style
|
|
18
17
|
from prompt_toolkit.widgets import Frame
|
|
19
|
-
from rich.console import Console
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
from ..utils.terminal_theme import get_adaptive_console, get_adaptive_prompt_style
|
|
20
|
+
|
|
21
|
+
console = get_adaptive_console()
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class DynamicCompletionsMenu(CompletionsMenu):
|
|
@@ -205,18 +205,8 @@ class InteractivePrompt:
|
|
|
205
205
|
)
|
|
206
206
|
)
|
|
207
207
|
|
|
208
|
-
#
|
|
209
|
-
style =
|
|
210
|
-
{
|
|
211
|
-
"frame.border": "#555555", # Subtle gray border
|
|
212
|
-
"frame.title": "#888888", # Muted title
|
|
213
|
-
"": "#ffffff", # Normal white text for input
|
|
214
|
-
"completion-menu.completion": "#ffffff bg:#333333", # Clean completion items
|
|
215
|
-
"completion-menu.completion.current": "#ffffff bg:#555555", # Selected completion
|
|
216
|
-
"completion-menu.meta.completion": "#aaaaaa bg:#222222", # Muted description
|
|
217
|
-
"completion-menu.meta.completion.current": "#ffffff bg:#444444", # Selected desc
|
|
218
|
-
}
|
|
219
|
-
)
|
|
208
|
+
# Adaptive style that works with both light and dark terminals
|
|
209
|
+
style = get_adaptive_prompt_style()
|
|
220
210
|
|
|
221
211
|
# Create application
|
|
222
212
|
app = Application(
|
|
@@ -13,17 +13,17 @@ from agents import (
|
|
|
13
13
|
)
|
|
14
14
|
from openai.types.responses import ResponseFunctionToolCall
|
|
15
15
|
from openai.types.responses.response_text_delta_event import ResponseTextDeltaEvent
|
|
16
|
-
from rich.console import
|
|
16
|
+
from rich.console import Group
|
|
17
17
|
from rich.live import Live
|
|
18
18
|
from rich.text import Text
|
|
19
19
|
|
|
20
|
-
from ..agentic import ApprovalHooks,
|
|
20
|
+
from ..agentic import ApprovalHooks, create_dev_agent, get_display_hooks
|
|
21
21
|
from ..core.context import ContextManager
|
|
22
|
-
from ..core.permissions import PermissionManager
|
|
23
22
|
from ..core.streaming_display import StreamingDisplayManager
|
|
24
23
|
from ..tools import get_all_tools
|
|
24
|
+
from ..utils.terminal_theme import get_adaptive_console
|
|
25
25
|
|
|
26
|
-
console =
|
|
26
|
+
console = get_adaptive_console()
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class AgentScheduler:
|
|
@@ -32,13 +32,12 @@ class AgentScheduler:
|
|
|
32
32
|
def __init__(self, session_id: str = "default", streaming: bool = False):
|
|
33
33
|
self.semaphore = asyncio.Semaphore(10)
|
|
34
34
|
self.context_manager = ContextManager(session_id)
|
|
35
|
-
self.permission_manager = PermissionManager()
|
|
36
35
|
self.tools = get_all_tools()
|
|
37
36
|
self.dev_agent = None # Will be initialized in async method
|
|
38
37
|
self.streaming = streaming
|
|
39
|
-
# Create
|
|
38
|
+
# Create hooks that wrap display hooks (no permissions)
|
|
40
39
|
display_hooks = get_display_hooks(streaming_mode=streaming)
|
|
41
|
-
self.hooks = ApprovalHooks(
|
|
40
|
+
self.hooks = ApprovalHooks(display_hooks)
|
|
42
41
|
self._agent_initialized = False
|
|
43
42
|
self._mcp_servers = [] # Track MCP servers for cleanup
|
|
44
43
|
|
|
@@ -122,10 +121,10 @@ class AgentScheduler:
|
|
|
122
121
|
print() # Add space before response
|
|
123
122
|
console.print(response)
|
|
124
123
|
print() # Add space after response
|
|
125
|
-
except
|
|
126
|
-
# Handle
|
|
124
|
+
except Exception as e:
|
|
125
|
+
# Handle execution errors gracefully
|
|
127
126
|
response = (
|
|
128
|
-
f"[red]Execution
|
|
127
|
+
f"[red]Execution error: {str(e)}[/red]\n\nPlease provide new instructions."
|
|
129
128
|
)
|
|
130
129
|
console.print(response)
|
|
131
130
|
return response
|
|
@@ -272,17 +271,13 @@ class AgentScheduler:
|
|
|
272
271
|
console.print(f"[dim red]Event processing error: {e}[/dim red]")
|
|
273
272
|
continue
|
|
274
273
|
|
|
275
|
-
except
|
|
276
|
-
# Handle
|
|
277
|
-
error_msg = f"Execution
|
|
274
|
+
except Exception as e:
|
|
275
|
+
# Handle execution errors in streaming mode
|
|
276
|
+
error_msg = f"Execution error: {str(e)}"
|
|
278
277
|
console.print(f"[red]{error_msg}[/red]")
|
|
279
278
|
# Clear the display manager and return early
|
|
280
279
|
display_manager.finalize_text_sections()
|
|
281
280
|
return f"{error_msg}\n\nPlease provide new instructions."
|
|
282
|
-
except Exception as e:
|
|
283
|
-
# Handle streaming errors
|
|
284
|
-
console.print(f"[dim red]Streaming error: {e}[/dim red]")
|
|
285
|
-
# Continue to try to get some output
|
|
286
281
|
|
|
287
282
|
# After Rich Live context ends, perform intelligent cleanup
|
|
288
283
|
display_manager.finalize_text_sections()
|
|
@@ -311,12 +306,19 @@ class AgentScheduler:
|
|
|
311
306
|
except Exception:
|
|
312
307
|
pass # Fallback to simple approach
|
|
313
308
|
|
|
314
|
-
# Strategy 2: Always show final
|
|
315
|
-
# Get the final
|
|
309
|
+
# Strategy 2: Always show final response with tools, but avoid duplicate tool output
|
|
310
|
+
# Get the final display content including tools
|
|
311
|
+
final_display_response = display_manager.get_final_display()
|
|
316
312
|
final_text_response = display_manager.get_final_text()
|
|
317
313
|
|
|
318
|
-
if
|
|
319
|
-
|
|
314
|
+
# Show the complete display including tools if available, otherwise fallback to text only
|
|
315
|
+
if final_display_response and final_display_response.strip():
|
|
316
|
+
# Show the complete response including tool summaries
|
|
317
|
+
print() # Add spacing
|
|
318
|
+
console.print(final_display_response)
|
|
319
|
+
print() # Add spacing after
|
|
320
|
+
elif final_text_response and final_text_response.strip():
|
|
321
|
+
# Fallback to text-only response
|
|
320
322
|
print() # Add spacing
|
|
321
323
|
console.print(final_text_response)
|
|
322
324
|
print() # Add spacing after
|
|
@@ -338,14 +340,14 @@ class AgentScheduler:
|
|
|
338
340
|
|
|
339
341
|
def _get_display_input(self, user_input: str) -> str:
|
|
340
342
|
"""Get a filtered version of user input for display purposes."""
|
|
341
|
-
# Check if input contains
|
|
342
|
-
if "
|
|
343
|
+
# Check if input contains AGENTS.md content
|
|
344
|
+
if "AGENTS.md content:" in user_input:
|
|
343
345
|
lines = user_input.split("\n")
|
|
344
346
|
filtered_lines = []
|
|
345
347
|
skip_koder_content = False
|
|
346
348
|
|
|
347
349
|
for line in lines:
|
|
348
|
-
if "
|
|
350
|
+
if "AGENTS.md content:" in line:
|
|
349
351
|
skip_koder_content = True
|
|
350
352
|
continue
|
|
351
353
|
elif skip_koder_content and line.startswith("User request:"):
|