-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Expand file tree
/
Copy path__init__.py
More file actions
46 lines (40 loc) · 1.17 KB
/
__init__.py
File metadata and controls
46 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""opencode integration."""
from ..base import MarkdownIntegration
class OpencodeIntegration(MarkdownIntegration):
key = "opencode"
config = {
"name": "opencode",
"folder": ".opencode/",
"commands_subdir": "commands",
"install_url": "https://opencode.ai",
"requires_cli": True,
}
registrar_config = {
"dir": ".opencode/commands",
"legacy_dir": ".opencode/command",
"format": "markdown",
"args": "$ARGUMENTS",
"extension": ".md",
}
context_file = "AGENTS.md"
def build_exec_args(
self,
prompt: str,
*,
model: str | None = None,
output_json: bool = True,
) -> list[str] | None:
args = [self.key, "run"]
message = prompt
if prompt.startswith("/"):
command, _, remainder = prompt[1:].partition(" ")
if command:
args.extend(["--command", command])
message = remainder
if model:
args.extend(["-m", model])
if output_json:
args.extend(["--format", "json"])
if message:
args.append(message)
return args