opencode icon indicating copy to clipboard operation
opencode copied to clipboard

需要一个每次启动自动执行的prompt功能

Open AndersHsueh opened this issue 10 months ago • 3 comments

建议增加一个功能,允许用户设置每次启动时自动执行的prompt,比如设置'##始终用中文回答##'这样的指令,这样就不用每次对话都重复输入相同的提示了。

AndersHsueh avatar Jan 20 '26 13:01 AndersHsueh

This issue might be a duplicate of existing issues. Please check:

  • #9610: How to globally set the language for model thinking and answering
  • #7101: [FEATURE]: Allow custom system prompts in global, project or custom directories
  • #7351: [FEATURE]: Add systemPrompt option to SDK like Claude Agent SDK
  • #3195: Dynamic system prompts for custom agents
  • #1894: add optional system prompt environment injection

These issues all relate to automatically executing or setting default instructions/prompts without having to repeat them in each conversation.

Feel free to ignore if your specific use case is different from these.

github-actions[bot] avatar Jan 20 '26 13:01 github-actions[bot]

该功能具备,请把该要求写入全局的AGENTS.md中,全局AGENTS.md与 opencode.json配置文件在同级目录。看下图:

Image

我的全局AGENTS.md示例:

# 输出语言
- 使用中文进行输出
- /init 命令生成的AGENTS.md以中文生成

zer0Black avatar Jan 20 '26 13:01 zer0Black

This issue has been addressed by PR #9625 which implements the autoexec prompt functionality.\n\nThe implementation adds:\n- autoexec_prompt field to config schema\n- Modified Session.initialize to execute autoexec prompts at session start\n- Allows users to set prompts that automatically execute, such as 'if gh command ready then do not use git command'

AndersHsueh avatar Jan 20 '26 13:01 AndersHsueh