Skip to content

Commit 6cda0df

Browse files
committed
adding prompt support for opencode
1 parent 27f6702 commit 6cda0df

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

code_assistant_manager/cli/prompts_commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
logger = logging.getLogger(__name__)
1313

1414
prompt_app = typer.Typer(
15-
help="Manage prompts for AI assistants (Claude, Codex, Gemini, Copilot, CodeBuddy)",
15+
help="Manage prompts for AI assistants (Claude, Codex, Gemini, Copilot, CodeBuddy, OpenCode)",
1616
no_args_is_help=True,
1717
)
1818

@@ -332,7 +332,7 @@ def remove_prompt(
332332
@prompt_app.command("import")
333333
def import_prompt(
334334
name: Optional[str] = typer.Argument(None, help="Name for the imported prompt (auto-generated if not provided)"),
335-
app: str = typer.Option(..., "--app", "-a", help=f"App to import from ({', '.join(VALID_APP_TYPES)})"),
335+
app: str = typer.Option(..., "--app", "-a", help=f"App to import from ({', '.join(VALID_APP_TYPES)}) - Note: opencode prompt = rules"),
336336
level: str = typer.Option("user", "--level", "-l", help="Level: user or project"),
337337
project_dir: Optional[Path] = typer.Option(None, "--project-dir", "-d", help="Project directory (for project level)"),
338338
description: Optional[str] = typer.Option(None, "--description", help="Description of the prompt"),
@@ -420,7 +420,7 @@ def import_prompt(
420420
@prompt_app.command("install")
421421
def install_prompt(
422422
name: str = typer.Argument(..., help="Prompt name to install"),
423-
app: str = typer.Option(..., "--app", "-a", help=f"Target app ({', '.join(VALID_APP_TYPES)})"),
423+
app: str = typer.Option(..., "--app", "-a", help=f"Target app ({', '.join(VALID_APP_TYPES)}) - Note: opencode prompt = rules"),
424424
level: str = typer.Option("user", "--level", "-l", help="Level: user or project"),
425425
project_dir: Optional[Path] = typer.Option(None, "--project-dir", "-d", help="Project directory (for project level)"),
426426
):
@@ -459,7 +459,7 @@ def install_prompt(
459459

460460
@prompt_app.command("uninstall")
461461
def uninstall_prompt(
462-
app: str = typer.Option(..., "--app", "-a", help=f"Target app ({', '.join(VALID_APP_TYPES)})"),
462+
app: str = typer.Option(..., "--app", "-a", help=f"Target app ({', '.join(VALID_APP_TYPES)}) - Note: opencode prompt = rules"),
463463
level: str = typer.Option("user", "--level", "-l", help="Level: user or project"),
464464
project_dir: Optional[Path] = typer.Option(None, "--project-dir", "-d", help="Project directory (for project level)"),
465465
force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation"),

code_assistant_manager/prompts/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- codex: OpenAI Codex CLI (~/.codex/AGENTS.md, ./AGENTS.md)
2424
- gemini: Google Gemini CLI (~/.gemini/GEMINI.md, ./GEMINI.md)
2525
- copilot: GitHub Copilot CLI (.github/copilot-instructions.md, .github/instructions/)
26+
- opencode: OpenCode (~/.config/opencode/AGENTS.md, ./AGENTS.md)
2627
"""
2728

2829
from .base import BasePromptHandler
@@ -36,6 +37,7 @@
3637
parse_copilot_frontmatter,
3738
)
3839
from .gemini import GeminiPromptHandler
40+
from .opencode import OpenCodePromptHandler
3941
from .manager import PROMPT_HANDLERS, VALID_APP_TYPES, PromptManager, get_handler
4042
from .models import Prompt
4143

@@ -44,12 +46,14 @@
4446
"claude": ClaudePromptHandler().user_prompt_path,
4547
"codex": CodexPromptHandler().user_prompt_path,
4648
"gemini": GeminiPromptHandler().user_prompt_path,
49+
"opencode": OpenCodePromptHandler().user_prompt_path,
4750
}
4851

4952
PROJECT_PROMPT_FILE_NAMES = {
5053
"claude": ClaudePromptHandler().project_prompt_filename,
5154
"codex": CodexPromptHandler().project_prompt_filename,
5255
"gemini": GeminiPromptHandler().project_prompt_filename,
56+
"opencode": OpenCodePromptHandler().project_prompt_filename,
5357
}
5458

5559
PROMPT_FILE_PATHS = USER_PROMPT_FILE_PATHS
@@ -80,6 +84,7 @@ def get_copilot_instructions_path(project_dir=None, repo_wide: bool = True):
8084
"CodexPromptHandler",
8185
"GeminiPromptHandler",
8286
"CopilotPromptHandler",
87+
"OpenCodePromptHandler",
8388
# Helper functions
8489
"get_handler",
8590
"get_prompt_file_path",

code_assistant_manager/prompts/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .codex import CodexPromptHandler
1414
from .copilot import CopilotPromptHandler
1515
from .gemini import GeminiPromptHandler
16+
from .opencode import OpenCodePromptHandler
1617
from .models import Prompt
1718

1819
logger = logging.getLogger(__name__)
@@ -24,6 +25,7 @@
2425
"gemini": GeminiPromptHandler,
2526
"copilot": CopilotPromptHandler,
2627
"codebuddy": CodebuddyPromptHandler,
28+
"opencode": OpenCodePromptHandler,
2729
}
2830

2931
# Valid app types
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""OpenCode-specific prompt handler."""
2+
3+
from pathlib import Path
4+
from typing import Optional
5+
6+
from .base import BasePromptHandler
7+
8+
9+
class OpenCodePromptHandler(BasePromptHandler):
10+
"""Prompt handler for OpenCode.
11+
12+
User-level prompt: ~/.config/opencode/AGENTS.md
13+
Project-level prompt: ./AGENTS.md
14+
"""
15+
16+
@property
17+
def tool_name(self) -> str:
18+
return "opencode"
19+
20+
@property
21+
def _default_user_prompt_path(self) -> Optional[Path]:
22+
return Path.home() / ".config" / "opencode" / "AGENTS.md"
23+
24+
@property
25+
def _default_project_prompt_filename(self) -> Optional[str]:
26+
return "AGENTS.md"

0 commit comments

Comments
 (0)