koder 0.4.4__tar.gz → 0.4.6__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.
Files changed (68) hide show
  1. {koder-0.4.4 → koder-0.4.6}/.claude/settings.local.json +6 -1
  2. {koder-0.4.4 → koder-0.4.6}/CLAUDE.md +6 -6
  3. {koder-0.4.4 → koder-0.4.6}/PKG-INFO +82 -3
  4. {koder-0.4.4 → koder-0.4.6}/README.md +81 -2
  5. {koder-0.4.4 → koder-0.4.6}/koder_agent/agentic/agent.py +43 -1
  6. koder-0.4.6/koder_agent/agentic/skill_guardrail.py +88 -0
  7. {koder-0.4.4 → koder-0.4.6}/koder_agent/cli.py +11 -17
  8. {koder-0.4.4 → koder-0.4.6}/koder_agent/config/models.py +13 -0
  9. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/__init__.py +38 -4
  10. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/engine.py +1 -0
  11. koder-0.4.6/koder_agent/tools/skill.py +403 -0
  12. koder-0.4.6/koder_agent/tools/skill_context.py +229 -0
  13. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/client.py +6 -6
  14. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/prompts.py +18 -11
  15. {koder-0.4.4 → koder-0.4.6}/pyproject.toml +1 -1
  16. koder-0.4.6/tests/fixtures/skills/large-skill/SKILL.md +106 -0
  17. koder-0.4.6/tests/fixtures/skills/large-skill/reference.md +24 -0
  18. koder-0.4.6/tests/fixtures/skills/medium-skill/SKILL.md +74 -0
  19. koder-0.4.6/tests/fixtures/skills/small-skill/SKILL.md +56 -0
  20. koder-0.4.6/tests/fixtures/skills/template-skill/SKILL.md +20 -0
  21. {koder-0.4.4 → koder-0.4.6}/tests/test_model_resolution.py +3 -5
  22. koder-0.4.6/tests/test_skill_loader.py +518 -0
  23. koder-0.4.6/tests/test_skill_restrictions.py +713 -0
  24. koder-0.4.6/tests/test_skill_token_efficiency.py +241 -0
  25. {koder-0.4.4 → koder-0.4.6}/uv.lock +4 -4
  26. {koder-0.4.4 → koder-0.4.6}/.github/dependabot.yml +0 -0
  27. {koder-0.4.4 → koder-0.4.6}/.gitignore +0 -0
  28. {koder-0.4.4 → koder-0.4.6}/AGENTS.md +0 -0
  29. {koder-0.4.4 → koder-0.4.6}/CONTRIBUTING.md +0 -0
  30. {koder-0.4.4 → koder-0.4.6}/GEMINI.md +0 -0
  31. {koder-0.4.4 → koder-0.4.6}/LICENSE +0 -0
  32. {koder-0.4.4 → koder-0.4.6}/koder_agent/__init__.py +0 -0
  33. {koder-0.4.4 → koder-0.4.6}/koder_agent/agentic/__init__.py +0 -0
  34. {koder-0.4.4 → koder-0.4.6}/koder_agent/agentic/approval_hooks.py +0 -0
  35. {koder-0.4.4 → koder-0.4.6}/koder_agent/agentic/hooks.py +0 -0
  36. {koder-0.4.4 → koder-0.4.6}/koder_agent/config/__init__.py +0 -0
  37. {koder-0.4.4 → koder-0.4.6}/koder_agent/config/cli_handler.py +0 -0
  38. {koder-0.4.4 → koder-0.4.6}/koder_agent/config/manager.py +0 -0
  39. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/__init__.py +0 -0
  40. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/commands.py +0 -0
  41. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/interactive.py +0 -0
  42. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/keyboard_listener.py +0 -0
  43. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/scheduler.py +0 -0
  44. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/security.py +0 -0
  45. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/session.py +0 -0
  46. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/status_line.py +0 -0
  47. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/streaming_display.py +0 -0
  48. {koder-0.4.4 → koder-0.4.6}/koder_agent/core/usage_tracker.py +0 -0
  49. {koder-0.4.4 → koder-0.4.6}/koder_agent/mcp/__init__.py +0 -0
  50. {koder-0.4.4 → koder-0.4.6}/koder_agent/mcp/cli_handler.py +0 -0
  51. {koder-0.4.4 → koder-0.4.6}/koder_agent/mcp/server_config.py +0 -0
  52. {koder-0.4.4 → koder-0.4.6}/koder_agent/mcp/server_factory.py +0 -0
  53. {koder-0.4.4 → koder-0.4.6}/koder_agent/mcp/server_manager.py +0 -0
  54. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/file.py +0 -0
  55. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/search.py +0 -0
  56. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/shell.py +0 -0
  57. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/task.py +0 -0
  58. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/todo.py +0 -0
  59. {koder-0.4.4 → koder-0.4.6}/koder_agent/tools/web.py +0 -0
  60. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/__init__.py +0 -0
  61. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/model_info.py +0 -0
  62. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/queue.py +0 -0
  63. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/sessions.py +0 -0
  64. {koder-0.4.4 → koder-0.4.6}/koder_agent/utils/terminal_theme.py +0 -0
  65. {koder-0.4.4 → koder-0.4.6}/scripts/upgrade_dependency.py +0 -0
  66. {koder-0.4.4 → koder-0.4.6}/tests/test_file_tools.py +0 -0
  67. {koder-0.4.4 → koder-0.4.6}/tests/test_shell_background.py +0 -0
  68. {koder-0.4.4 → koder-0.4.6}/tests/test_web.py +0 -0
@@ -6,7 +6,12 @@
6
6
  "Bash(python -m py_compile:*)",
7
7
  "Bash(uv run pytest:*)",
8
8
  "mcp__plugin_claude-code-settings_exa__get_code_context_exa",
9
- "Bash(find:*)"
9
+ "Bash(find:*)",
10
+ "WebFetch(domain:www.anthropic.com)",
11
+ "Bash(uv run ruff check:*)",
12
+ "mcp__firecrawl__firecrawl_scrape",
13
+ "Bash(uv run:*)",
14
+ "Bash(uv run pip:*)"
10
15
  ],
11
16
  "deny": [],
12
17
  "ask": []
@@ -24,26 +24,26 @@ uv run koder --session my-session "Your prompt"
24
24
 
25
25
  ```bash
26
26
  # Code formatting
27
- black .
27
+ uv run black .
28
28
 
29
29
  # Linting with auto-fix
30
- ruff check --fix
30
+ uv run ruff check --fix
31
31
 
32
32
  # Error-only pylint check
33
- pylint koder_agent/ --disable=C,R,W --errors-only
33
+ uv run pylint koder_agent/ --disable=C,R,W --errors-only
34
34
  ```
35
35
 
36
36
  ### Testing
37
37
 
38
38
  ```bash
39
39
  # Run all tests
40
- pytest
40
+ uv run pytest
41
41
 
42
42
  # Run a single test file
43
- pytest tests/test_file_tools.py
43
+ uv run pytest tests/test_file_tools.py
44
44
 
45
45
  # Run with verbose output
46
- pytest -v
46
+ uv run pytest -v
47
47
  ```
48
48
 
49
49
  ## Architecture
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koder
3
- Version: 0.4.4
3
+ Version: 0.4.6
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
@@ -40,14 +40,15 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  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.
42
42
 
43
- **🎯 Project Status**: Under active vibe coding! This is a learning-focused project where we explore building AI coding agents.
43
+ **🎯 Project Status**: Alpha! This is a learning-focused project where we explore building AI coding agents.
44
44
 
45
45
  ## ✨ Features
46
46
 
47
47
  - **🤖 Universal AI Support**: Works with OpenAI, Anthropic, Google, GitHub Copilot, and 100+ providers via LiteLLM with intelligent auto-detection
48
48
  - **💾 Smart Context Management**: Persistent sessions with SQLite storage and automatic token-aware compression (50k token limit)
49
49
  - **🔄 Real-time Streaming**: Rich Live displays with intelligent terminal cleanup for responsive user experience
50
- - **🛠️ Comprehensive Toolset**: file operations, search, shell, task delegation and todos.
50
+ - **🛠️ Comprehensive Toolset**: file operations, search, shell, task delegation, todos, and skills
51
+ - **📚 Progressive Disclosure Skills**: Load specialized knowledge on-demand with 90%+ token savings
51
52
  - **🔌 MCP Integration**: Model Context Protocol support with stdio, SSE, and HTTP transports for extensible tool ecosystem
52
53
  - **🛡️ Enterprise Security**: SecurityGuard validation, output filtering, permission system, and input sanitization
53
54
  - **🎯 Zero Configuration**: Automatic provider detection with fallback defaults
@@ -350,6 +351,84 @@ mcp_servers:
350
351
  url: "http://localhost:9000/sse"
351
352
  ```
352
353
 
354
+ ### Skills
355
+
356
+ Skills provide specialized knowledge and guidance that Koder can load on-demand. This uses a **Progressive Disclosure** pattern to minimize token usage - only skill metadata is loaded at startup, with full content fetched when needed.
357
+
358
+ #### Skills Directory Structure
359
+
360
+ Skills are loaded from two locations (project skills take priority):
361
+
362
+ 1. **Project skills**: `.koder/skills/` in your current directory
363
+ 2. **User skills**: `~/.koder/skills/` for personal skills
364
+
365
+ Each skill lives in its own directory with a `SKILL.md` file:
366
+
367
+ ```
368
+ .koder/skills/
369
+ ├── api-design/
370
+ │ └── SKILL.md
371
+ ├── code-review/
372
+ │ ├── SKILL.md
373
+ │ └── checklist.md # Supplementary resource
374
+ └── testing/
375
+ └── SKILL.md
376
+ ```
377
+
378
+ #### Creating a Skill
379
+
380
+ Create a `SKILL.md` file with YAML frontmatter:
381
+
382
+ ```markdown
383
+ ---
384
+ name: api-design
385
+ description: Best practices for designing RESTful APIs
386
+ allowed_tools:
387
+ - read_file
388
+ - write_file
389
+ ---
390
+
391
+ # API Design Guidelines
392
+
393
+ ## RESTful Principles
394
+
395
+ Use nouns for resources, HTTP verbs for actions...
396
+
397
+ ## Versioning
398
+
399
+ Always version your APIs using URL path (`/v1/users`)...
400
+
401
+ ## Error Handling
402
+
403
+ Return consistent error responses with status codes...
404
+ ```
405
+
406
+ #### Frontmatter Fields
407
+
408
+ | Field | Required | Description |
409
+ |-------|----------|-------------|
410
+ | `name` | Yes | Unique skill identifier |
411
+ | `description` | Yes | Brief description (shown in metadata) |
412
+ | `allowed_tools` | No | Tools the skill recommends using |
413
+
414
+ #### How Skills Work
415
+
416
+ 1. **Startup**: Only skill names and descriptions are loaded (Level 1 - minimal tokens)
417
+ 2. **On-demand**: When Koder needs a skill, it calls `get_skill(name)` to load full content (Level 2)
418
+ 3. **Supplementary**: Skills can reference additional files that Koder reads with `read_file` (Level 3)
419
+
420
+ This progressive approach saves **90%+ tokens** compared to loading all skill content at startup.
421
+
422
+ #### Skills Configuration
423
+
424
+ ```yaml
425
+ # ~/.koder/config.yaml
426
+ skills:
427
+ enabled: true # Enable/disable skills (default: true)
428
+ project_skills_dir: ".koder/skills" # Project skills location
429
+ user_skills_dir: "~/.koder/skills" # User skills location
430
+ ```
431
+
353
432
  ### Example Configurations
354
433
 
355
434
  <details>
@@ -4,14 +4,15 @@
4
4
 
5
5
  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.
6
6
 
7
- **🎯 Project Status**: Under active vibe coding! This is a learning-focused project where we explore building AI coding agents.
7
+ **🎯 Project Status**: Alpha! This is a learning-focused project where we explore building AI coding agents.
8
8
 
9
9
  ## ✨ Features
10
10
 
11
11
  - **🤖 Universal AI Support**: Works with OpenAI, Anthropic, Google, GitHub Copilot, and 100+ providers via LiteLLM with intelligent auto-detection
12
12
  - **💾 Smart Context Management**: Persistent sessions with SQLite storage and automatic token-aware compression (50k token limit)
13
13
  - **🔄 Real-time Streaming**: Rich Live displays with intelligent terminal cleanup for responsive user experience
14
- - **🛠️ Comprehensive Toolset**: file operations, search, shell, task delegation and todos.
14
+ - **🛠️ Comprehensive Toolset**: file operations, search, shell, task delegation, todos, and skills
15
+ - **📚 Progressive Disclosure Skills**: Load specialized knowledge on-demand with 90%+ token savings
15
16
  - **🔌 MCP Integration**: Model Context Protocol support with stdio, SSE, and HTTP transports for extensible tool ecosystem
16
17
  - **🛡️ Enterprise Security**: SecurityGuard validation, output filtering, permission system, and input sanitization
17
18
  - **🎯 Zero Configuration**: Automatic provider detection with fallback defaults
@@ -314,6 +315,84 @@ mcp_servers:
314
315
  url: "http://localhost:9000/sse"
315
316
  ```
316
317
 
318
+ ### Skills
319
+
320
+ Skills provide specialized knowledge and guidance that Koder can load on-demand. This uses a **Progressive Disclosure** pattern to minimize token usage - only skill metadata is loaded at startup, with full content fetched when needed.
321
+
322
+ #### Skills Directory Structure
323
+
324
+ Skills are loaded from two locations (project skills take priority):
325
+
326
+ 1. **Project skills**: `.koder/skills/` in your current directory
327
+ 2. **User skills**: `~/.koder/skills/` for personal skills
328
+
329
+ Each skill lives in its own directory with a `SKILL.md` file:
330
+
331
+ ```
332
+ .koder/skills/
333
+ ├── api-design/
334
+ │ └── SKILL.md
335
+ ├── code-review/
336
+ │ ├── SKILL.md
337
+ │ └── checklist.md # Supplementary resource
338
+ └── testing/
339
+ └── SKILL.md
340
+ ```
341
+
342
+ #### Creating a Skill
343
+
344
+ Create a `SKILL.md` file with YAML frontmatter:
345
+
346
+ ```markdown
347
+ ---
348
+ name: api-design
349
+ description: Best practices for designing RESTful APIs
350
+ allowed_tools:
351
+ - read_file
352
+ - write_file
353
+ ---
354
+
355
+ # API Design Guidelines
356
+
357
+ ## RESTful Principles
358
+
359
+ Use nouns for resources, HTTP verbs for actions...
360
+
361
+ ## Versioning
362
+
363
+ Always version your APIs using URL path (`/v1/users`)...
364
+
365
+ ## Error Handling
366
+
367
+ Return consistent error responses with status codes...
368
+ ```
369
+
370
+ #### Frontmatter Fields
371
+
372
+ | Field | Required | Description |
373
+ |-------|----------|-------------|
374
+ | `name` | Yes | Unique skill identifier |
375
+ | `description` | Yes | Brief description (shown in metadata) |
376
+ | `allowed_tools` | No | Tools the skill recommends using |
377
+
378
+ #### How Skills Work
379
+
380
+ 1. **Startup**: Only skill names and descriptions are loaded (Level 1 - minimal tokens)
381
+ 2. **On-demand**: When Koder needs a skill, it calls `get_skill(name)` to load full content (Level 2)
382
+ 3. **Supplementary**: Skills can reference additional files that Koder reads with `read_file` (Level 3)
383
+
384
+ This progressive approach saves **90%+ tokens** compared to loading all skill content at startup.
385
+
386
+ #### Skills Configuration
387
+
388
+ ```yaml
389
+ # ~/.koder/config.yaml
390
+ skills:
391
+ enabled: true # Enable/disable skills (default: true)
392
+ project_skills_dir: ".koder/skills" # Project skills location
393
+ user_skills_dir: "~/.koder/skills" # User skills location
394
+ ```
395
+
317
396
  ### Example Configurations
318
397
 
319
398
  <details>
@@ -2,6 +2,7 @@
2
2
 
3
3
  import logging
4
4
  import uuid
5
+ from pathlib import Path
5
6
 
6
7
  import backoff
7
8
  import litellm
@@ -12,6 +13,7 @@ from rich.console import Console
12
13
 
13
14
  from ..config import get_config
14
15
  from ..mcp import load_mcp_servers
16
+ from ..tools.skill import SkillLoader
15
17
  from ..utils.client import get_litellm_model_kwargs, get_model_name, is_native_openai_provider
16
18
  from ..utils.model_info import get_maximum_output_tokens
17
19
  from ..utils.prompts import KODER_SYSTEM_PROMPT
@@ -52,6 +54,42 @@ class RetryingLitellmModel(LitellmModel):
52
54
  yield chunk
53
55
 
54
56
 
57
+ def _get_skills_metadata(config) -> str:
58
+ """Load and return skills metadata from configured directories.
59
+
60
+ Priority: project skills directory > user skills directory.
61
+ Skills with the same name in project dir override user dir.
62
+ """
63
+ if not config.skills.enabled:
64
+ return "Skills are disabled."
65
+
66
+ all_skills = {}
67
+
68
+ # Load user skills first (lower priority)
69
+ user_dir = Path(config.skills.user_skills_dir).expanduser()
70
+ if user_dir.exists():
71
+ user_loader = SkillLoader(user_dir)
72
+ for skill in user_loader.discover_skills():
73
+ all_skills[skill.name] = skill
74
+
75
+ # Load project skills (higher priority - overrides user skills)
76
+ project_dir = Path(config.skills.project_skills_dir)
77
+ if project_dir.exists():
78
+ project_loader = SkillLoader(project_dir)
79
+ for skill in project_loader.discover_skills():
80
+ all_skills[skill.name] = skill
81
+
82
+ if not all_skills:
83
+ return "No skills are currently available."
84
+
85
+ lines = ["Available skills:", ""]
86
+ for skill in sorted(all_skills.values(), key=lambda s: s.name.lower()):
87
+ description = skill.description.strip()
88
+ lines.append(f"- {skill.name}: {description}")
89
+
90
+ return "\n".join(lines)
91
+
92
+
55
93
  async def create_dev_agent(tools) -> Agent:
56
94
  """Create the main development agent with MCP servers."""
57
95
  config = get_config()
@@ -80,10 +118,14 @@ async def create_dev_agent(tools) -> Agent:
80
118
  effort = None if config.model.reasoning_effort == "none" else config.model.reasoning_effort
81
119
  model_settings.reasoning = Reasoning(effort=effort, summary="detailed")
82
120
 
121
+ # Build system prompt with skills metadata (Progressive Disclosure Level 1)
122
+ skills_metadata = _get_skills_metadata(config)
123
+ system_prompt = KODER_SYSTEM_PROMPT.replace("{SKILLS_METADATA}", skills_metadata)
124
+
83
125
  dev_agent = Agent(
84
126
  name="Koder",
85
127
  model=model,
86
- instructions=KODER_SYSTEM_PROMPT,
128
+ instructions=system_prompt,
87
129
  tools=tools,
88
130
  mcp_servers=mcp_servers,
89
131
  model_settings=model_settings,
@@ -0,0 +1,88 @@
1
+ """Guardrail for enforcing skill-based tool restrictions.
2
+
3
+ This module provides a ToolInputGuardrail that intercepts tool calls and
4
+ rejects those not permitted by the currently active skill restrictions.
5
+
6
+ When a skill with `allowed_tools` is loaded via get_skill(), subsequent
7
+ tool calls are validated against the allowed list. Tools not in the list
8
+ are rejected with an informative message.
9
+ """
10
+
11
+ from agents import (
12
+ ToolGuardrailFunctionOutput,
13
+ ToolInputGuardrail,
14
+ ToolInputGuardrailData,
15
+ )
16
+
17
+ from ..tools.skill_context import get_active_restrictions
18
+
19
+
20
+ def skill_tool_restriction_guardrail(
21
+ data: ToolInputGuardrailData,
22
+ ) -> ToolGuardrailFunctionOutput:
23
+ """Guardrail that enforces skill-declared tool restrictions.
24
+
25
+ When a skill is loaded with `allowed_tools`, only those tools
26
+ (plus always-allowed tools like get_skill, todo_read, todo_write)
27
+ can be used.
28
+
29
+ Supports pattern matching for fine-grained control:
30
+ - "read_file" - Exact tool name match
31
+ - "run_shell:git *" - Shell commands matching glob pattern
32
+ - "run_shell:*" - All shell commands allowed
33
+ - "*" - Wildcard, all tools allowed
34
+
35
+ Args:
36
+ data: The guardrail input data containing tool context
37
+
38
+ Returns:
39
+ ToolGuardrailFunctionOutput indicating whether to allow or reject
40
+ """
41
+ restrictions = get_active_restrictions()
42
+
43
+ # No active restrictions - allow all tools
44
+ if restrictions is None:
45
+ return ToolGuardrailFunctionOutput.allow()
46
+
47
+ # Guard against missing or empty tool_name (defensive coding)
48
+ tool_name = getattr(data.context, "tool_name", "") or ""
49
+ if not tool_name:
50
+ # Unknown tool - reject with clear message
51
+ return ToolGuardrailFunctionOutput.reject_content(
52
+ message="Unable to verify tool: tool name is missing or empty",
53
+ output_info={"error": "missing_tool_name"},
54
+ )
55
+
56
+ # Get tool arguments for pattern matching (e.g., shell command matching)
57
+ tool_args = getattr(data.context, "tool_arguments", None)
58
+
59
+ # Check if tool is allowed (with pattern matching support)
60
+ if restrictions.is_tool_allowed(tool_name, tool_args):
61
+ return ToolGuardrailFunctionOutput.allow()
62
+
63
+ # Tool is not allowed - reject with informative message
64
+ allowed_list = ", ".join(sorted(restrictions.allowed_tools))
65
+ skills_list = ", ".join(restrictions.loaded_skills)
66
+
67
+ message = (
68
+ f"Tool '{tool_name}' is not permitted while skill(s) [{skills_list}] "
69
+ f"are active with tool restrictions. "
70
+ f"Allowed tools: {allowed_list}. "
71
+ f"You can load a skill without restrictions to clear these limits."
72
+ )
73
+
74
+ return ToolGuardrailFunctionOutput.reject_content(
75
+ message=message,
76
+ output_info={
77
+ "blocked_tool": tool_name,
78
+ "active_skills": restrictions.loaded_skills,
79
+ "allowed_tools": list(restrictions.allowed_tools),
80
+ },
81
+ )
82
+
83
+
84
+ # Create the guardrail instance for use in agent configuration
85
+ skill_restriction_guardrail = ToolInputGuardrail(
86
+ guardrail_function=skill_tool_restriction_guardrail,
87
+ name="skill_tool_restrictions",
88
+ )
@@ -132,11 +132,8 @@ async def main():
132
132
  parser.add_argument(
133
133
  "--resume", action="store_true", help="List and select a previous session to resume"
134
134
  )
135
- stream_group = parser.add_mutually_exclusive_group()
136
- stream_group.add_argument(
137
- "--stream", action="store_true", help="Force enable streaming mode"
138
- )
139
- stream_group.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
135
+ parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
136
+ parser.add_argument("--debug", action="store_true", help="Enable debug logging")
140
137
 
141
138
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
142
139
  create_mcp_subparsers(subparsers)
@@ -148,11 +145,8 @@ async def main():
148
145
  parser.add_argument(
149
146
  "--resume", action="store_true", help="List and select a previous session to resume"
150
147
  )
151
- stream_group = parser.add_mutually_exclusive_group()
152
- stream_group.add_argument(
153
- "--stream", action="store_true", help="Force enable streaming mode"
154
- )
155
- stream_group.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
148
+ parser.add_argument("--no-stream", action="store_true", help="Disable streaming mode")
149
+ parser.add_argument("--debug", action="store_true", help="Enable debug logging")
156
150
 
157
151
  parser.add_argument(
158
152
  "prompt", nargs="*", help="Prompt text (if not provided, starts interactive mode)"
@@ -160,6 +154,11 @@ async def main():
160
154
 
161
155
  args = parser.parse_args()
162
156
 
157
+ # Configure logging level based on --debug flag
158
+ if args.debug:
159
+ logging.getLogger().setLevel(logging.DEBUG)
160
+ logging.debug("Debug logging enabled")
161
+
163
162
  # Set command to None for prompt mode
164
163
  if not hasattr(args, "command"):
165
164
  args.command = None
@@ -195,13 +194,8 @@ async def main():
195
194
 
196
195
  context = await load_context()
197
196
 
198
- # Determine streaming setting: CLI flag overrides config
199
- if args.stream:
200
- streaming = True
201
- elif args.no_stream:
202
- streaming = False
203
- else:
204
- streaming = config.cli.stream
197
+ # Determine streaming setting: --no-stream overrides config default
198
+ streaming = config.cli.stream and not args.no_stream
205
199
 
206
200
  scheduler = AgentScheduler(session_id=args.session, streaming=streaming)
207
201
 
@@ -71,9 +71,22 @@ class MCPServerConfigYaml(BaseModel):
71
71
  blocked_tools: Optional[List[str]] = Field(default=None, description="Blocked tools blacklist")
72
72
 
73
73
 
74
+ class SkillsConfig(BaseModel):
75
+ """Skills configuration settings for progressive disclosure."""
76
+
77
+ enabled: bool = Field(default=True, description="Enable skills feature")
78
+ project_skills_dir: str = Field(
79
+ default=".koder/skills", description="Project-level skills directory"
80
+ )
81
+ user_skills_dir: str = Field(
82
+ default="~/.koder/skills", description="User-level skills directory"
83
+ )
84
+
85
+
74
86
  class KoderConfig(BaseModel):
75
87
  """Root configuration model for Koder CLI."""
76
88
 
77
89
  model: ModelConfig = Field(default_factory=ModelConfig)
78
90
  cli: CLIConfig = Field(default_factory=CLIConfig)
79
91
  mcp_servers: List[MCPServerConfigYaml] = Field(default_factory=list)
92
+ skills: SkillsConfig = Field(default_factory=SkillsConfig)
@@ -2,8 +2,9 @@
2
2
 
3
3
  from typing import List
4
4
 
5
- from agents import Tool
5
+ from agents import FunctionTool, Tool
6
6
 
7
+ from ..agentic.skill_guardrail import skill_restriction_guardrail
7
8
  from .engine import ToolEngine
8
9
  from .file import (
9
10
  FileEditModel,
@@ -28,6 +29,14 @@ from .shell import (
28
29
  shell_kill,
29
30
  shell_output,
30
31
  )
32
+ from .skill import Skill, SkillLoader, SkillModel, get_skill
33
+ from .skill_context import (
34
+ SkillRestrictions,
35
+ add_skill_restrictions,
36
+ clear_restrictions,
37
+ get_active_restrictions,
38
+ has_active_restrictions,
39
+ )
31
40
  from .task import TaskDelegateModel, TaskModel, task_delegate
32
41
  from .todo import TodoModel, TodoWriteModel, todo_read, todo_write
33
42
  from .web import SearchModel, WebFetchModel, web_fetch, web_search
@@ -49,13 +58,18 @@ tool_engine.register(GrepModel)(grep_search)
49
58
  tool_engine.register(LSModel)(list_directory)
50
59
  # TODO tools are already registered via @function_tool decorator
51
60
  # Removing duplicate registration to avoid naming conflicts
61
+ tool_engine.register(SkillModel)(get_skill)
52
62
  tool_engine.register(WebFetchModel)(web_fetch)
53
63
  tool_engine.register(TaskDelegateModel)(task_delegate)
54
64
  tool_engine.register(GitModel)(git_command)
55
65
 
56
66
 
57
67
  def get_all_tools() -> List[Tool]:
58
- """Get all registered tools as a list."""
68
+ """Get all registered tools as a list.
69
+
70
+ Each FunctionTool is configured with the skill_restriction_guardrail
71
+ to enforce skill-based tool restrictions when skills are active.
72
+ """
59
73
  # Collect all @function_tool decorated functions directly
60
74
  tools = [
61
75
  read_file,
@@ -74,10 +88,21 @@ def get_all_tools() -> List[Tool]:
74
88
  todo_read,
75
89
  todo_write,
76
90
  task_delegate,
91
+ get_skill,
77
92
  ]
78
93
 
79
- # Filter to only include properly decorated tools
80
- return [tool for tool in tools if hasattr(tool, "name")]
94
+ # Filter to only include properly decorated tools and attach guardrails
95
+ result = []
96
+ for tool in tools:
97
+ if hasattr(tool, "name"):
98
+ # Attach skill restriction guardrail to each FunctionTool
99
+ if isinstance(tool, FunctionTool):
100
+ if tool.tool_input_guardrails is None:
101
+ tool.tool_input_guardrails = [skill_restriction_guardrail]
102
+ elif skill_restriction_guardrail not in tool.tool_input_guardrails:
103
+ tool.tool_input_guardrails.append(skill_restriction_guardrail)
104
+ result.append(tool)
105
+ return result
81
106
 
82
107
 
83
108
  __all__ = [
@@ -98,6 +123,14 @@ __all__ = [
98
123
  "WebFetchModel",
99
124
  "GlobModel",
100
125
  "GrepModel",
126
+ "Skill",
127
+ "SkillLoader",
128
+ "SkillModel",
129
+ "SkillRestrictions",
130
+ "add_skill_restrictions",
131
+ "clear_restrictions",
132
+ "get_active_restrictions",
133
+ "has_active_restrictions",
101
134
  "TodoModel",
102
135
  "TodoWriteModel",
103
136
  "TaskModel",
@@ -119,4 +152,5 @@ __all__ = [
119
152
  "todo_read",
120
153
  "todo_write",
121
154
  "task_delegate",
155
+ "get_skill",
122
156
  ]
@@ -119,6 +119,7 @@ class ToolEngine:
119
119
  "todo_write",
120
120
  "web_fetch",
121
121
  "task_delegate",
122
+ "get_skill",
122
123
  "git_command",
123
124
  }
124
125
  return name in allowed_tools