Skip to content

feat: add autoexec prompt functionality - #9625

Closed
AndersHsueh wants to merge 2 commits into
anomalyco:devfrom
AndersHsueh:feature/autoexec-prompt
Closed

AndersHsueh wants to merge 2 commits into
anomalyco:devfrom
AndersHsueh:feature/autoexec-prompt

Conversation

@AndersHsueh

@AndersHsueh AndersHsueh commented Jan 20, 2026 •

Copy link
Copy Markdown

This PR adds functionality to execute autoexec prompts at session start.\n\n- Add autoexec_prompt field to config schema\n- Modify Session.initialize to execute autoexec prompts at session start\n- This allows users to set prompts that automatically execute, such as 'if gh command ready then do not use git command'

resolved issue #9615

- Add autoexec_prompt field to config schema
- Modify Session.initialize to execute autoexec prompts at session start
- This allows users to set prompts that automatically execute,
  such as 'if gh command ready then do not use git command'

Co-authored-by: Qwen-Coder <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@AndersHsueh

Copy link
Copy Markdown
Author

使用方法:Autoexec Prompt 功能

此 PR 实现了 autoexec prompt 功能,以下是使用方法:

配置方式

在您的配置文件(如 opencode.json 或 opencode.jsonc)中添加 autoexec_prompt 字段:

{
  "autoexec_prompt": [
    "if gh command ready then do not use git command",
    "Please remember to use gh command instead of git command when available.",
    "This is an auto-executed prompt to set the context for the conversation."
  ]
}

配置文件位置

您可以将此配置放在以下任一位置:

  • 项目根目录下的 opencode.json 或 opencode.jsonc
  • 全局配置目录中的 opencode.json 或 opencode.jsonc
  • .opencode 子目录中的配置文件

功能说明

  • 配置中的每个字符串都会在会话初始化时自动作为提示执行
  • 这些提示会在每次新会话开始时自动运行
  • 用户可以设置任何需要在会话开始时自动执行的指令
  • 例如,可以设置语言偏好、工具使用偏好等

此功能允许您设置像 'if gh command ready then do not use git command' 这样的指令,这样就不需要在每次开始新会话时重复输入相同的提示了。

@AndersHsueh

Copy link
Copy Markdown
Author

Usage Guide: Autoexec Prompt Feature

This PR implements the autoexec prompt functionality. Here's how to use it:

Configuration

Add the autoexec_prompt field to your configuration file (such as opencode.json or opencode.jsonc):

{
  "autoexec_prompt": [
    "if gh command ready then do not use git command",
    "Please remember to use gh command instead of git command when available.",
    "This is an auto-executed prompt to set the context for the conversation."
  ]
}

Configuration File Locations

You can place this configuration in any of the following locations:

  • opencode.json or opencode.jsonc in your project root directory
  • opencode.json or opencode.jsonc in your global configuration directory
  • Configuration files in the .opencode subdirectory

Feature Description

  • Each string in the configuration will be automatically executed as a prompt during session initialization
  • These prompts will run automatically at the start of each new session
  • Users can set any instructions they want to execute automatically at session start
  • For example, you can set language preferences, tool usage preferences, etc.

This feature allows you to set instructions like 'if gh command ready then do not use git command' so you don't have to repeatedly input the same prompts every time you start a new session.

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant