2026-04-01 09:17:21 -05:00
|
|
|
"""opencode integration."""
|
|
|
|
|
|
|
|
|
|
from ..base import MarkdownIntegration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OpencodeIntegration(MarkdownIntegration):
|
|
|
|
|
key = "opencode"
|
|
|
|
|
config = {
|
|
|
|
|
"name": "opencode",
|
|
|
|
|
"folder": ".opencode/",
|
2026-05-13 16:55:56 +02:00
|
|
|
"commands_subdir": "commands",
|
2026-04-01 09:17:21 -05:00
|
|
|
"install_url": "https://opencode.ai",
|
|
|
|
|
"requires_cli": True,
|
|
|
|
|
}
|
|
|
|
|
registrar_config = {
|
2026-05-13 16:55:56 +02:00
|
|
|
"dir": ".opencode/commands",
|
|
|
|
|
"legacy_dir": ".opencode/command",
|
2026-04-01 09:17:21 -05:00
|
|
|
"format": "markdown",
|
|
|
|
|
"args": "$ARGUMENTS",
|
|
|
|
|
"extension": ".md",
|
|
|
|
|
}
|
|
|
|
|
context_file = "AGENTS.md"
|
2026-04-29 17:39:45 +03:00
|
|
|
|
|
|
|
|
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
|