imbue-mngr-opencode 0.2.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.
- imbue/mngr_opencode/__init__.py +0 -0
- imbue/mngr_opencode/plugin.py +55 -0
- imbue/mngr_opencode/plugin_test.py +25 -0
- imbue/mngr_opencode/test_ratchets.py +255 -0
- imbue_mngr_opencode-0.2.0.dist-info/METADATA +43 -0
- imbue_mngr_opencode-0.2.0.dist-info/RECORD +8 -0
- imbue_mngr_opencode-0.2.0.dist-info/WHEEL +4 -0
- imbue_mngr_opencode-0.2.0.dist-info/entry_points.txt +2 -0
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from imbue.mngr import hookimpl
|
|
4
|
+
from imbue.mngr.config.data_types import AgentTypeConfig
|
|
5
|
+
from imbue.mngr.errors import ConfigParseError
|
|
6
|
+
from imbue.mngr.interfaces.agent import AgentInterface
|
|
7
|
+
from imbue.mngr.primitives import CommandString
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class OpenCodeAgentConfig(AgentTypeConfig):
|
|
11
|
+
"""Config for the opencode agent type."""
|
|
12
|
+
|
|
13
|
+
command: CommandString = Field(
|
|
14
|
+
default=CommandString("opencode"),
|
|
15
|
+
description="Command to run opencode agent",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def merge_with(self, override: AgentTypeConfig) -> AgentTypeConfig:
|
|
19
|
+
"""
|
|
20
|
+
Merge this config with an override config.
|
|
21
|
+
|
|
22
|
+
Important note: despite the type signatures, any of these fields may be None in the override--this means that they were NOT set in the toml (and thus should be ignored)
|
|
23
|
+
"""
|
|
24
|
+
if not isinstance(override, OpenCodeAgentConfig):
|
|
25
|
+
raise ConfigParseError("Cannot merge OpenCodeAgentConfig with different agent config type")
|
|
26
|
+
|
|
27
|
+
# Merge parent_type (scalar - override wins if not None)
|
|
28
|
+
merged_parent_type = override.parent_type if override.parent_type is not None else self.parent_type
|
|
29
|
+
|
|
30
|
+
# Merge command (scalar - override wins if not None)
|
|
31
|
+
merged_command = self.command
|
|
32
|
+
if hasattr(override, "command") and override.command is not None:
|
|
33
|
+
merged_command = override.command
|
|
34
|
+
|
|
35
|
+
# Merge cli_args (concatenate both tuples)
|
|
36
|
+
merged_cli_args = self.cli_args + override.cli_args if override.cli_args else self.cli_args
|
|
37
|
+
|
|
38
|
+
# Merge permissions (list - concatenate if override is not None)
|
|
39
|
+
merged_permissions = self.permissions
|
|
40
|
+
if override.permissions is not None:
|
|
41
|
+
merged_permissions = list(self.permissions) + list(override.permissions)
|
|
42
|
+
|
|
43
|
+
return self.__class__(
|
|
44
|
+
parent_type=merged_parent_type,
|
|
45
|
+
cli_args=merged_cli_args,
|
|
46
|
+
command=merged_command,
|
|
47
|
+
permissions=merged_permissions,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Module-level hook implementation for pluggy entry point discovery
|
|
52
|
+
@hookimpl
|
|
53
|
+
def register_agent_type() -> tuple[str, type[AgentInterface] | None, type[AgentTypeConfig]]:
|
|
54
|
+
"""Register the opencode agent type."""
|
|
55
|
+
return ("opencode", None, OpenCodeAgentConfig)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Unit tests for OpenCodeAgentConfig."""
|
|
2
|
+
|
|
3
|
+
from imbue.mngr_opencode.plugin import OpenCodeAgentConfig
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_opencode_agent_config_has_correct_defaults() -> None:
|
|
7
|
+
"""Verify that OpenCodeAgentConfig has the expected default values."""
|
|
8
|
+
config = OpenCodeAgentConfig()
|
|
9
|
+
|
|
10
|
+
assert str(config.command) == "opencode"
|
|
11
|
+
assert config.cli_args == ()
|
|
12
|
+
assert config.permissions == []
|
|
13
|
+
assert config.parent_type is None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_opencode_agent_config_merge_with_override() -> None:
|
|
17
|
+
"""Verify that merge_with works correctly for OpenCodeAgentConfig."""
|
|
18
|
+
base = OpenCodeAgentConfig()
|
|
19
|
+
override = OpenCodeAgentConfig(cli_args=("--verbose",))
|
|
20
|
+
|
|
21
|
+
merged = base.merge_with(override)
|
|
22
|
+
|
|
23
|
+
assert isinstance(merged, OpenCodeAgentConfig)
|
|
24
|
+
assert merged.cli_args == ("--verbose",)
|
|
25
|
+
assert str(merged.command) == "opencode"
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from inline_snapshot import snapshot
|
|
5
|
+
|
|
6
|
+
from imbue.imbue_common.ratchet_testing import standard_ratchet_checks as rc
|
|
7
|
+
from imbue.imbue_common.ratchet_testing.ratchets import check_no_ruff_errors
|
|
8
|
+
from imbue.imbue_common.ratchet_testing.ratchets import check_no_type_errors
|
|
9
|
+
|
|
10
|
+
_DIR = Path(__file__).parent.parent.parent
|
|
11
|
+
|
|
12
|
+
pytestmark = pytest.mark.xdist_group(name="ratchets")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# --- Code safety ---
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_prevent_todos() -> None:
|
|
19
|
+
rc.check_todos(_DIR, snapshot(0))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_prevent_exec_usage() -> None:
|
|
23
|
+
rc.check_exec(_DIR, snapshot(0))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_prevent_eval_usage() -> None:
|
|
27
|
+
rc.check_eval(_DIR, snapshot(0))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_prevent_while_true() -> None:
|
|
31
|
+
rc.check_while_true(_DIR, snapshot(0))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_prevent_time_sleep() -> None:
|
|
35
|
+
rc.check_time_sleep(_DIR, snapshot(0))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_prevent_global_keyword() -> None:
|
|
39
|
+
rc.check_global_keyword(_DIR, snapshot(0))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_prevent_bare_print() -> None:
|
|
43
|
+
rc.check_bare_print(_DIR, snapshot(0))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# --- Exception handling ---
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_prevent_bare_except() -> None:
|
|
50
|
+
rc.check_bare_except(_DIR, snapshot(0))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_prevent_broad_exception_catch() -> None:
|
|
54
|
+
rc.check_broad_exception_catch(_DIR, snapshot(0))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_prevent_base_exception_catch() -> None:
|
|
58
|
+
rc.check_base_exception_catch(_DIR, snapshot(0))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_prevent_builtin_exception_raises() -> None:
|
|
62
|
+
rc.check_builtin_exception_raises(_DIR, snapshot(0))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# --- Import style ---
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_prevent_inline_imports() -> None:
|
|
69
|
+
rc.check_inline_imports(_DIR, snapshot(0))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_prevent_relative_imports() -> None:
|
|
73
|
+
rc.check_relative_imports(_DIR, snapshot(0))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_prevent_import_datetime() -> None:
|
|
77
|
+
rc.check_import_datetime(_DIR, snapshot(0))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_prevent_importlib_import_module() -> None:
|
|
81
|
+
rc.check_importlib_import_module(_DIR, snapshot(0))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_prevent_getattr() -> None:
|
|
85
|
+
rc.check_getattr(_DIR, snapshot(0))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_prevent_setattr() -> None:
|
|
89
|
+
rc.check_setattr(_DIR, snapshot(0))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# --- Banned libraries and patterns ---
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_prevent_asyncio_import() -> None:
|
|
96
|
+
rc.check_asyncio_import(_DIR, snapshot(0))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_prevent_pandas_import() -> None:
|
|
100
|
+
rc.check_pandas_import(_DIR, snapshot(0))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_prevent_dataclasses_import() -> None:
|
|
104
|
+
rc.check_dataclasses_import(_DIR, snapshot(0))
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_prevent_namedtuple_usage() -> None:
|
|
108
|
+
rc.check_namedtuple(_DIR, snapshot(0))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_prevent_yaml_usage() -> None:
|
|
112
|
+
rc.check_yaml_usage(_DIR, snapshot(0))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_prevent_functools_partial() -> None:
|
|
116
|
+
rc.check_functools_partial(_DIR, snapshot(0))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# --- Naming conventions ---
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_prevent_num_prefix() -> None:
|
|
123
|
+
rc.check_num_prefix(_DIR, snapshot(0))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# --- Documentation ---
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_prevent_trailing_comments() -> None:
|
|
130
|
+
rc.check_trailing_comments(_DIR, snapshot(0))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_prevent_init_docstrings() -> None:
|
|
134
|
+
rc.check_init_docstrings(_DIR, snapshot(0))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@pytest.mark.timeout(10)
|
|
138
|
+
def test_prevent_args_in_docstrings() -> None:
|
|
139
|
+
rc.check_args_in_docstrings(_DIR, snapshot(0))
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@pytest.mark.timeout(10)
|
|
143
|
+
def test_prevent_returns_in_docstrings() -> None:
|
|
144
|
+
rc.check_returns_in_docstrings(_DIR, snapshot(0))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# --- Type safety ---
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def test_prevent_literal_with_multiple_options() -> None:
|
|
151
|
+
rc.check_literal_with_multiple_options(_DIR, snapshot(0))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_prevent_bare_generic_types() -> None:
|
|
155
|
+
rc.check_bare_generic_types(_DIR, snapshot(0))
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def test_prevent_typing_builtin_imports() -> None:
|
|
159
|
+
rc.check_typing_builtin_imports(_DIR, snapshot(0))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def test_prevent_short_uuid_ids() -> None:
|
|
163
|
+
rc.check_short_uuid_ids(_DIR, snapshot(0))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# --- Pydantic / models ---
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_prevent_model_copy() -> None:
|
|
170
|
+
rc.check_model_copy(_DIR, snapshot(0))
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# --- Logging ---
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_prevent_fstring_logging() -> None:
|
|
177
|
+
rc.check_fstring_logging(_DIR, snapshot(0))
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_prevent_click_echo() -> None:
|
|
181
|
+
rc.check_click_echo(_DIR, snapshot(0))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
# --- Testing conventions ---
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def test_prevent_unittest_mock_imports() -> None:
|
|
188
|
+
rc.check_unittest_mock_imports(_DIR, snapshot(0))
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_prevent_monkeypatch_setattr() -> None:
|
|
192
|
+
rc.check_monkeypatch_setattr(_DIR, snapshot(0))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_prevent_test_container_classes() -> None:
|
|
196
|
+
rc.check_test_container_classes(_DIR, snapshot(0))
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def test_prevent_pytest_mark_integration() -> None:
|
|
200
|
+
rc.check_pytest_mark_integration(_DIR, snapshot(0))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
# --- Process management ---
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_prevent_os_fork() -> None:
|
|
207
|
+
rc.check_os_fork(_DIR, snapshot(0))
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def test_prevent_direct_subprocess_usage() -> None:
|
|
211
|
+
rc.check_direct_subprocess(_DIR, snapshot(0))
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
# --- AST-based ratchets ---
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_prevent_if_elif_without_else() -> None:
|
|
218
|
+
rc.check_if_elif_without_else(_DIR, snapshot(0))
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def test_prevent_inline_functions_in_non_test_code() -> None:
|
|
222
|
+
rc.check_inline_functions(_DIR, snapshot(0))
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def test_prevent_importing_underscore_prefixed_names_in_non_test_code() -> None:
|
|
226
|
+
rc.check_underscore_imports(_DIR, snapshot(0))
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def test_prevent_init_methods_in_non_exception_classes() -> None:
|
|
230
|
+
rc.check_init_methods_in_non_exception_classes(_DIR, snapshot(0))
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def test_prevent_cast_usage() -> None:
|
|
234
|
+
rc.check_cast_usage(_DIR, snapshot(0))
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def test_prevent_assert_isinstance_usage() -> None:
|
|
238
|
+
rc.check_assert_isinstance(_DIR, snapshot(0))
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# --- Project-level checks ---
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def test_prevent_code_in_init_files() -> None:
|
|
245
|
+
rc.check_code_in_init_files(_DIR, snapshot(0))
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def test_no_type_errors() -> None:
|
|
249
|
+
"""Ensure the codebase has zero type errors."""
|
|
250
|
+
check_no_type_errors(_DIR)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def test_no_ruff_errors() -> None:
|
|
254
|
+
"""Ensure the codebase has zero ruff linting errors."""
|
|
255
|
+
check_no_ruff_errors(_DIR)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: imbue-mngr-opencode
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: OpenCode agent type plugin for mngr
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Requires-Dist: imbue-mngr==0.2.0
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# imbue-mngr-opencode
|
|
10
|
+
|
|
11
|
+
Plugin that registers the `opencode` agent type for mngr.
|
|
12
|
+
|
|
13
|
+
[OpenCode](https://github.com/sst/opencode) is an open-source terminal-based AI coding assistant. This plugin lets you run it as an mngr agent.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
mngr create my-agent opencode
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Pass arguments to the opencode command with `--`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
mngr create my-agent opencode -- --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
Define a custom variant in your mngr config (`mngr config edit`):
|
|
30
|
+
|
|
31
|
+
```toml
|
|
32
|
+
[agent_types.my_opencode]
|
|
33
|
+
parent_type = "opencode"
|
|
34
|
+
cli_args = "--some-flag"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then create agents with your custom type:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
mngr create my-agent my_opencode
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See the [mngr agent types documentation](https://github.com/imbue-ai/mngr/blob/main/libs/mngr/docs/concepts/agent_types.md) for more details.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
imbue/mngr_opencode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
imbue/mngr_opencode/plugin.py,sha256=VmBbGpvwXmNxPU2uwz7LJsIRtxjXomHwslkNrrCFTKY,2254
|
|
3
|
+
imbue/mngr_opencode/plugin_test.py,sha256=dfqHUGalXfbKT9RFG7zbPiMhRutVe_103RBNrmCjRQ8,843
|
|
4
|
+
imbue/mngr_opencode/test_ratchets.py,sha256=fpHczdLMBHvmko6Dh_k7E0vhfc2efPBJngSyDD8NMU8,5721
|
|
5
|
+
imbue_mngr_opencode-0.2.0.dist-info/METADATA,sha256=zyh-CpzAFgE3XEGeh24d9OoLynVnPfKYIwALTvJ2Sp0,995
|
|
6
|
+
imbue_mngr_opencode-0.2.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
7
|
+
imbue_mngr_opencode-0.2.0.dist-info/entry_points.txt,sha256=78f6wk2fdFHHJ8ltL94prcLHHU7NfIb7vXrTLLsQLs8,45
|
|
8
|
+
imbue_mngr_opencode-0.2.0.dist-info/RECORD,,
|