|
| 1 | +/** |
| 2 | + * OpenCode's default plan agent system prompt. |
| 3 | + * |
| 4 | + * This prompt enforces READ-ONLY mode for the plan agent, preventing any file |
| 5 | + * modifications and ensuring the agent focuses solely on analysis and planning. |
| 6 | + * |
| 7 | + * @see https://github.com/sst/opencode/blob/db2abc1b2c144f63a205f668bd7267e00829d84a/packages/opencode/src/session/prompt/plan.txt |
| 8 | + */ |
| 9 | +export const PLAN_SYSTEM_PROMPT = `<system-reminder> |
| 10 | +# Plan Mode - System Reminder |
| 11 | +
|
| 12 | +CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN: |
| 13 | +ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat, |
| 14 | +or ANY other bash command to manipulate files - commands may ONLY read/inspect. |
| 15 | +This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user |
| 16 | +edit requests. You may ONLY observe, analyze, and plan. Any modification attempt |
| 17 | +is a critical violation. ZERO exceptions. |
| 18 | +
|
| 19 | +--- |
| 20 | +
|
| 21 | +## Responsibility |
| 22 | +
|
| 23 | +Your current responsibility is to think, read, search, and delegate explore agents to construct a well formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity. |
| 24 | +
|
| 25 | +Ask the user clarifying questions or ask for their opinion when weighing tradeoffs. |
| 26 | +
|
| 27 | +**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins. |
| 28 | +
|
| 29 | +--- |
| 30 | +
|
| 31 | +## Important |
| 32 | +
|
| 33 | +The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received. |
| 34 | +</system-reminder> |
| 35 | +` |
| 36 | + |
| 37 | +/** |
| 38 | + * OpenCode's default plan agent permission configuration. |
| 39 | + * |
| 40 | + * Restricts the plan agent to read-only operations: |
| 41 | + * - edit: "deny" - No file modifications allowed |
| 42 | + * - bash: Only read-only commands (ls, grep, git log, etc.) |
| 43 | + * - webfetch: "allow" - Can fetch web content for research |
| 44 | + * |
| 45 | + * @see https://github.com/sst/opencode/blob/db2abc1b2c144f63a205f668bd7267e00829d84a/packages/opencode/src/agent/agent.ts#L63-L107 |
| 46 | + */ |
| 47 | +export const PLAN_PERMISSION = { |
| 48 | + edit: "deny" as const, |
| 49 | + bash: { |
| 50 | + "cut*": "allow" as const, |
| 51 | + "diff*": "allow" as const, |
| 52 | + "du*": "allow" as const, |
| 53 | + "file *": "allow" as const, |
| 54 | + "find * -delete*": "ask" as const, |
| 55 | + "find * -exec*": "ask" as const, |
| 56 | + "find * -fprint*": "ask" as const, |
| 57 | + "find * -fls*": "ask" as const, |
| 58 | + "find * -fprintf*": "ask" as const, |
| 59 | + "find * -ok*": "ask" as const, |
| 60 | + "find *": "allow" as const, |
| 61 | + "git diff*": "allow" as const, |
| 62 | + "git log*": "allow" as const, |
| 63 | + "git show*": "allow" as const, |
| 64 | + "git status*": "allow" as const, |
| 65 | + "git branch": "allow" as const, |
| 66 | + "git branch -v": "allow" as const, |
| 67 | + "grep*": "allow" as const, |
| 68 | + "head*": "allow" as const, |
| 69 | + "less*": "allow" as const, |
| 70 | + "ls*": "allow" as const, |
| 71 | + "more*": "allow" as const, |
| 72 | + "pwd*": "allow" as const, |
| 73 | + "rg*": "allow" as const, |
| 74 | + "sort --output=*": "ask" as const, |
| 75 | + "sort -o *": "ask" as const, |
| 76 | + "sort*": "allow" as const, |
| 77 | + "stat*": "allow" as const, |
| 78 | + "tail*": "allow" as const, |
| 79 | + "tree -o *": "ask" as const, |
| 80 | + "tree*": "allow" as const, |
| 81 | + "uniq*": "allow" as const, |
| 82 | + "wc*": "allow" as const, |
| 83 | + "whereis*": "allow" as const, |
| 84 | + "which*": "allow" as const, |
| 85 | + "*": "ask" as const, |
| 86 | + }, |
| 87 | + webfetch: "allow" as const, |
| 88 | +} |
0 commit comments