Skip to content

Commit f6a5096

Browse files
committed
Add plan agent system prompt and permission configuration to OmO-Plan
Completes the OmO-Plan implementation by providing the READ-ONLY system prompt and permission configuration that enforce plan-specific constraints. This ensures OmO-Plan operates in pure analysis and planning mode without file modifications. Fixes: #77 References: #72, #75 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
1 parent 0625ebb commit f6a5096

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

src/agents/plan-prompt.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
}

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { BackgroundManager } from "./features/background-agent";
5050
import { createBuiltinMcps } from "./mcp";
5151
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig, type HookName } from "./config";
5252
import { log, deepMerge } from "./shared";
53+
import { PLAN_SYSTEM_PROMPT, PLAN_PERMISSION } from "./agents/plan-prompt";
5354
import * as fs from "fs";
5455
import * as path from "path";
5556
import * as os from "os";
@@ -313,11 +314,15 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
313314
const omoPlanOverride = pluginConfig.agents?.["OmO-Plan"];
314315
const omoPlanBase = {
315316
...planConfigWithoutName,
317+
prompt: PLAN_SYSTEM_PROMPT,
318+
permission: PLAN_PERMISSION,
316319
description: `${config.agent?.plan?.description ?? "Plan agent"} (OhMyOpenCode version)`,
317320
color: config.agent?.plan?.color ?? "#6495ED",
318321
};
319322

320-
const omoPlanConfig = omoPlanOverride ? deepMerge(omoPlanBase, omoPlanOverride) : omoPlanBase;
323+
const omoPlanConfig = omoPlanOverride
324+
? { ...omoPlanBase, ...omoPlanOverride }
325+
: omoPlanBase;
321326

322327
config.agent = {
323328
OmO: builtinAgents.OmO,

0 commit comments

Comments
 (0)