coder-agent 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coder_agent-0.1.0.dist-info/METADATA +262 -0
- coder_agent-0.1.0.dist-info/RECORD +163 -0
- coder_agent-0.1.0.dist-info/WHEEL +5 -0
- coder_agent-0.1.0.dist-info/entry_points.txt +2 -0
- coder_agent-0.1.0.dist-info/licenses/LICENSE.md +21 -0
- coder_agent-0.1.0.dist-info/top_level.txt +1 -0
- coderagent/__init__.py +20 -0
- coderagent/compat/__init__.py +27 -0
- coderagent/compat/cache_control.py +69 -0
- coderagent/compat/config_spec.py +60 -0
- coderagent/compat/exceptions.py +20 -0
- coderagent/compat/retry.py +27 -0
- coderagent/compat/serialize.py +31 -0
- coderagent/config/__init__.py +1 -0
- coderagent/config/defaults.yaml +103 -0
- coderagent/config/loader.py +264 -0
- coderagent/config/schema.py +548 -0
- coderagent/config/writer.py +218 -0
- coderagent/core/__init__.py +1 -0
- coderagent/core/budget.py +47 -0
- coderagent/core/capabilities.py +136 -0
- coderagent/core/checkpoint.py +164 -0
- coderagent/core/content.py +156 -0
- coderagent/core/context.py +618 -0
- coderagent/core/events.py +83 -0
- coderagent/core/history.py +56 -0
- coderagent/core/instructions.py +99 -0
- coderagent/core/loop.py +702 -0
- coderagent/core/memory.py +56 -0
- coderagent/core/mentions.py +81 -0
- coderagent/core/os_sandbox.py +191 -0
- coderagent/core/otel.py +214 -0
- coderagent/core/protocols.py +38 -0
- coderagent/core/redact.py +49 -0
- coderagent/core/sandbox.py +82 -0
- coderagent/core/schema.py +107 -0
- coderagent/core/session.py +344 -0
- coderagent/core/shell_env.py +74 -0
- coderagent/core/subagent.py +474 -0
- coderagent/core/summarize.py +312 -0
- coderagent/core/telemetry.py +209 -0
- coderagent/core/tokens.py +132 -0
- coderagent/core/trust.py +301 -0
- coderagent/environments/__init__.py +11 -0
- coderagent/environments/bubblewrap.py +150 -0
- coderagent/environments/contree.py +146 -0
- coderagent/environments/docker.py +160 -0
- coderagent/environments/local.py +110 -0
- coderagent/environments/singularity.py +138 -0
- coderagent/environments/swerex_docker.py +79 -0
- coderagent/environments/swerex_modal.py +123 -0
- coderagent/eval/__init__.py +1 -0
- coderagent/eval/compare.py +190 -0
- coderagent/eval/report.py +141 -0
- coderagent/eval/runner.py +368 -0
- coderagent/eval/task.py +194 -0
- coderagent/extensions/__init__.py +1 -0
- coderagent/extensions/hooks.py +121 -0
- coderagent/extensions/plugins.py +217 -0
- coderagent/extensions/reflect.py +342 -0
- coderagent/models/__init__.py +33 -0
- coderagent/models/backends.py +218 -0
- coderagent/models/call.py +18 -0
- coderagent/models/check.py +139 -0
- coderagent/models/gateway.py +60 -0
- coderagent/models/litellm_config.py +70 -0
- coderagent/models/provider.py +98 -0
- coderagent/models/reasoning.py +28 -0
- coderagent/models/router.py +136 -0
- coderagent/models/settings.py +172 -0
- coderagent/models/streaming.py +122 -0
- coderagent/models/verbosity.py +14 -0
- coderagent/paths.py +31 -0
- coderagent/run.py +454 -0
- coderagent/skills/__init__.py +119 -0
- coderagent/skills/errors.py +11 -0
- coderagent/skills/install.py +340 -0
- coderagent/skills/presets/code-review/SKILL.md +35 -0
- coderagent/skills/presets/codebase-onboarding/SKILL.md +33 -0
- coderagent/skills/presets/data-analysis/SKILL.md +35 -0
- coderagent/skills/presets/deep-research/SKILL.md +38 -0
- coderagent/skills/presets/frontend-dev/SKILL.md +32 -0
- coderagent/skills/presets/long-document/SKILL.md +37 -0
- coderagent/skills/presets/long-document/scripts/pdf_text.py +37 -0
- coderagent/skills/presets/office-docx/SKILL.md +36 -0
- coderagent/skills/presets/office-docx/scripts/docx_text.py +36 -0
- coderagent/skills/presets/office-pptx/SKILL.md +32 -0
- coderagent/skills/presets/office-xlsx/SKILL.md +34 -0
- coderagent/skills/presets/office-xlsx/scripts/xlsx_text.py +72 -0
- coderagent/skills/presets/writing/SKILL.md +31 -0
- coderagent/skills/sandbox.py +269 -0
- coderagent/skills/sites.py +177 -0
- coderagent/skills/source.py +404 -0
- coderagent/testing/__init__.py +5 -0
- coderagent/testing/factory.py +59 -0
- coderagent/testing/scripted_model.py +54 -0
- coderagent/tools/__init__.py +1 -0
- coderagent/tools/base.py +54 -0
- coderagent/tools/bash_policy.py +486 -0
- coderagent/tools/builtin/__init__.py +35 -0
- coderagent/tools/builtin/fs.py +283 -0
- coderagent/tools/builtin/patch.py +279 -0
- coderagent/tools/builtin/search.py +242 -0
- coderagent/tools/builtin/shell.py +336 -0
- coderagent/tools/builtin/skill.py +41 -0
- coderagent/tools/builtin/task.py +53 -0
- coderagent/tools/builtin/todo.py +63 -0
- coderagent/tools/executor.py +243 -0
- coderagent/tools/mcp.py +317 -0
- coderagent/tools/permissions.py +472 -0
- coderagent/tools/registry.py +83 -0
- coderagent/tools/rules.py +138 -0
- coderagent/ui/__init__.py +1 -0
- coderagent/ui/cli.py +498 -0
- coderagent/ui/commands/__init__.py +109 -0
- coderagent/ui/commands/builtin.py +778 -0
- coderagent/ui/commands/compact.py +12 -0
- coderagent/ui/commands/resume.py +26 -0
- coderagent/ui/commands/review.py +73 -0
- coderagent/ui/commands/rewind.py +28 -0
- coderagent/ui/custom_commands.py +179 -0
- coderagent/ui/notify.py +46 -0
- coderagent/ui/open_file.py +48 -0
- coderagent/ui/render.py +62 -0
- coderagent/ui/spinner.py +68 -0
- coderagent/ui/tui.py +610 -0
- coderagent/ui/widgets/__init__.py +29 -0
- coderagent/ui/widgets/approval_prompt.py +129 -0
- coderagent/ui/widgets/diff_view.py +97 -0
- coderagent/ui/widgets/file_tree.py +105 -0
- coderagent/ui/widgets/markdown_message.py +44 -0
- coderagent/ui/widgets/markup.py +10 -0
- coderagent/ui/widgets/message_block.py +61 -0
- coderagent/ui/widgets/path_suggester.py +66 -0
- coderagent/ui/widgets/session_picker.py +49 -0
- coderagent/ui/widgets/status_bar.py +44 -0
- coderagent/ui/widgets/todo_panel.py +40 -0
- coderagent/ui/widgets/tool_card.py +104 -0
- coderagent/ui/widgets/working_dots.py +26 -0
- coderagent/version.py +7 -0
- coderagent/web/__init__.py +5 -0
- coderagent/web/api.py +449 -0
- coderagent/web/app.py +113 -0
- coderagent/web/approver.py +73 -0
- coderagent/web/config_api.py +53 -0
- coderagent/web/events.py +159 -0
- coderagent/web/files.py +115 -0
- coderagent/web/i18n.py +346 -0
- coderagent/web/server.py +100 -0
- coderagent/web/sessions.py +404 -0
- coderagent/web/skills_api.py +376 -0
- coderagent/web/static/app.css +283 -0
- coderagent/web/static/app.js +1466 -0
- coderagent/web/templates/en/base.html +31 -0
- coderagent/web/templates/en/chat.html +60 -0
- coderagent/web/templates/en/macros.html +9 -0
- coderagent/web/templates/en/settings.html +80 -0
- coderagent/web/templates/en/skills.html +64 -0
- coderagent/web/templates/zh/base.html +31 -0
- coderagent/web/templates/zh/chat.html +60 -0
- coderagent/web/templates/zh/macros.html +9 -0
- coderagent/web/templates/zh/settings.html +77 -0
- coderagent/web/templates/zh/skills.html +61 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""The slash commands the user can type.
|
|
2
|
+
|
|
3
|
+
A command is a function of the context: it reads the core objects and writes its
|
|
4
|
+
answer through `context.say`. The UI only has to notice the leading slash and
|
|
5
|
+
hand the line over.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from coderagent.config.schema import Config
|
|
14
|
+
from coderagent.core.checkpoint import CheckpointStore
|
|
15
|
+
from coderagent.core.events import EventBus
|
|
16
|
+
from coderagent.core.loop import AgentLoop
|
|
17
|
+
from coderagent.core.session import Session, SessionStore
|
|
18
|
+
from coderagent.tools.permissions import PermissionPolicy
|
|
19
|
+
from coderagent.ui.custom_commands import find_custom, run_custom
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class CommandContext:
|
|
24
|
+
"""What a command can reach."""
|
|
25
|
+
|
|
26
|
+
loop: AgentLoop
|
|
27
|
+
session: Session
|
|
28
|
+
store: SessionStore
|
|
29
|
+
bus: EventBus
|
|
30
|
+
cwd: Path
|
|
31
|
+
config: Config
|
|
32
|
+
policy: PermissionPolicy
|
|
33
|
+
checkpoints: CheckpointStore | None = None
|
|
34
|
+
mcp: Any = None
|
|
35
|
+
"""The MCP manager, when one is running."""
|
|
36
|
+
output: Callable[[str], None] = print
|
|
37
|
+
"""Where the answer goes."""
|
|
38
|
+
submit: Callable[..., None] | None = None
|
|
39
|
+
"""Run a turn with this prompt. None when the interface cannot run one.
|
|
40
|
+
|
|
41
|
+
The prompt is a string, or the parts of a message that carries images.
|
|
42
|
+
The second argument is the purpose of the turn: it says which model
|
|
43
|
+
answers it. It is empty for the main model.
|
|
44
|
+
"""
|
|
45
|
+
submit_side: Callable[[str, Session], None] | None = None
|
|
46
|
+
"""Run a turn in a session of its own, and come back. None when the
|
|
47
|
+
interface cannot run one."""
|
|
48
|
+
quit: Callable[[], None] | None = None
|
|
49
|
+
"""How to leave the interface. None when there is nothing to leave."""
|
|
50
|
+
|
|
51
|
+
def say(self, text: str) -> None:
|
|
52
|
+
self.output(text)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class Command:
|
|
57
|
+
name: str
|
|
58
|
+
description: str
|
|
59
|
+
handler: Callable[[CommandContext, str], None]
|
|
60
|
+
aliases: list[str] = field(default_factory=list)
|
|
61
|
+
usage: str = ""
|
|
62
|
+
"""What the command takes, when it takes something."""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
COMMANDS: list[Command] = []
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def register(command: Command) -> Command:
|
|
69
|
+
"""Add a command. A command with the same name replaces the one that is there."""
|
|
70
|
+
for index, existing in enumerate(COMMANDS):
|
|
71
|
+
if existing.name == command.name:
|
|
72
|
+
COMMANDS[index] = command
|
|
73
|
+
return command
|
|
74
|
+
COMMANDS.append(command)
|
|
75
|
+
return command
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def find(name: str) -> Command | None:
|
|
79
|
+
"""The command with this name or one of its aliases."""
|
|
80
|
+
name = name.lstrip("/").lower()
|
|
81
|
+
for command in COMMANDS:
|
|
82
|
+
if command.name == name or name in command.aliases:
|
|
83
|
+
return command
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def load_builtins() -> None:
|
|
88
|
+
"""Register the built-in commands. Calling it twice does nothing."""
|
|
89
|
+
if COMMANDS:
|
|
90
|
+
return
|
|
91
|
+
from coderagent.ui.commands import builtin # noqa: F401
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def run(context: CommandContext, line: str) -> bool:
|
|
95
|
+
"""Run the command in this line. Returns False when the line is not a command."""
|
|
96
|
+
if not line.startswith("/"):
|
|
97
|
+
return False
|
|
98
|
+
load_builtins()
|
|
99
|
+
name, _, argument = line[1:].partition(" ")
|
|
100
|
+
custom = find_custom(context.cwd, name)
|
|
101
|
+
if custom is not None:
|
|
102
|
+
run_custom(context, custom, argument.strip())
|
|
103
|
+
return True
|
|
104
|
+
command = find(name)
|
|
105
|
+
if command is None:
|
|
106
|
+
context.say(f"Unknown command '/{name}'. Try /help.")
|
|
107
|
+
return True
|
|
108
|
+
command.handler(context, argument.strip())
|
|
109
|
+
return True
|