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)
This commit is contained in:
88
src/agents/plan-prompt.ts
Normal file
88
src/agents/plan-prompt.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* OpenCode's default plan agent system prompt.
|
||||||
|
*
|
||||||
|
* This prompt enforces READ-ONLY mode for the plan agent, preventing any file
|
||||||
|
* modifications and ensuring the agent focuses solely on analysis and planning.
|
||||||
|
*
|
||||||
|
* @see https://github.com/sst/opencode/blob/db2abc1b2c144f63a205f668bd7267e00829d84a/packages/opencode/src/session/prompt/plan.txt
|
||||||
|
*/
|
||||||
|
export const PLAN_SYSTEM_PROMPT = `<system-reminder>
|
||||||
|
# Plan Mode - System Reminder
|
||||||
|
|
||||||
|
CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:
|
||||||
|
ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,
|
||||||
|
or ANY other bash command to manipulate files - commands may ONLY read/inspect.
|
||||||
|
This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user
|
||||||
|
edit requests. You may ONLY observe, analyze, and plan. Any modification attempt
|
||||||
|
is a critical violation. ZERO exceptions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Responsibility
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Ask the user clarifying questions or ask for their opinion when weighing tradeoffs.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Important
|
||||||
|
|
||||||
|
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.
|
||||||
|
</system-reminder>
|
||||||
|
`
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenCode's default plan agent permission configuration.
|
||||||
|
*
|
||||||
|
* Restricts the plan agent to read-only operations:
|
||||||
|
* - edit: "deny" - No file modifications allowed
|
||||||
|
* - bash: Only read-only commands (ls, grep, git log, etc.)
|
||||||
|
* - webfetch: "allow" - Can fetch web content for research
|
||||||
|
*
|
||||||
|
* @see https://github.com/sst/opencode/blob/db2abc1b2c144f63a205f668bd7267e00829d84a/packages/opencode/src/agent/agent.ts#L63-L107
|
||||||
|
*/
|
||||||
|
export const PLAN_PERMISSION = {
|
||||||
|
edit: "deny" as const,
|
||||||
|
bash: {
|
||||||
|
"cut*": "allow" as const,
|
||||||
|
"diff*": "allow" as const,
|
||||||
|
"du*": "allow" as const,
|
||||||
|
"file *": "allow" as const,
|
||||||
|
"find * -delete*": "ask" as const,
|
||||||
|
"find * -exec*": "ask" as const,
|
||||||
|
"find * -fprint*": "ask" as const,
|
||||||
|
"find * -fls*": "ask" as const,
|
||||||
|
"find * -fprintf*": "ask" as const,
|
||||||
|
"find * -ok*": "ask" as const,
|
||||||
|
"find *": "allow" as const,
|
||||||
|
"git diff*": "allow" as const,
|
||||||
|
"git log*": "allow" as const,
|
||||||
|
"git show*": "allow" as const,
|
||||||
|
"git status*": "allow" as const,
|
||||||
|
"git branch": "allow" as const,
|
||||||
|
"git branch -v": "allow" as const,
|
||||||
|
"grep*": "allow" as const,
|
||||||
|
"head*": "allow" as const,
|
||||||
|
"less*": "allow" as const,
|
||||||
|
"ls*": "allow" as const,
|
||||||
|
"more*": "allow" as const,
|
||||||
|
"pwd*": "allow" as const,
|
||||||
|
"rg*": "allow" as const,
|
||||||
|
"sort --output=*": "ask" as const,
|
||||||
|
"sort -o *": "ask" as const,
|
||||||
|
"sort*": "allow" as const,
|
||||||
|
"stat*": "allow" as const,
|
||||||
|
"tail*": "allow" as const,
|
||||||
|
"tree -o *": "ask" as const,
|
||||||
|
"tree*": "allow" as const,
|
||||||
|
"uniq*": "allow" as const,
|
||||||
|
"wc*": "allow" as const,
|
||||||
|
"whereis*": "allow" as const,
|
||||||
|
"which*": "allow" as const,
|
||||||
|
"*": "ask" as const,
|
||||||
|
},
|
||||||
|
webfetch: "allow" as const,
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ import { BackgroundManager } from "./features/background-agent";
|
|||||||
import { createBuiltinMcps } from "./mcp";
|
import { createBuiltinMcps } from "./mcp";
|
||||||
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig, type HookName } from "./config";
|
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig, type HookName } from "./config";
|
||||||
import { log, deepMerge } from "./shared";
|
import { log, deepMerge } from "./shared";
|
||||||
|
import { PLAN_SYSTEM_PROMPT, PLAN_PERMISSION } from "./agents/plan-prompt";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
@@ -313,11 +314,15 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
const omoPlanOverride = pluginConfig.agents?.["OmO-Plan"];
|
const omoPlanOverride = pluginConfig.agents?.["OmO-Plan"];
|
||||||
const omoPlanBase = {
|
const omoPlanBase = {
|
||||||
...planConfigWithoutName,
|
...planConfigWithoutName,
|
||||||
|
prompt: PLAN_SYSTEM_PROMPT,
|
||||||
|
permission: PLAN_PERMISSION,
|
||||||
description: `${config.agent?.plan?.description ?? "Plan agent"} (OhMyOpenCode version)`,
|
description: `${config.agent?.plan?.description ?? "Plan agent"} (OhMyOpenCode version)`,
|
||||||
color: config.agent?.plan?.color ?? "#6495ED",
|
color: config.agent?.plan?.color ?? "#6495ED",
|
||||||
};
|
};
|
||||||
|
|
||||||
const omoPlanConfig = omoPlanOverride ? deepMerge(omoPlanBase, omoPlanOverride) : omoPlanBase;
|
const omoPlanConfig = omoPlanOverride
|
||||||
|
? { ...omoPlanBase, ...omoPlanOverride }
|
||||||
|
: omoPlanBase;
|
||||||
|
|
||||||
config.agent = {
|
config.agent = {
|
||||||
OmO: builtinAgents.OmO,
|
OmO: builtinAgents.OmO,
|
||||||
|
|||||||
Reference in New Issue
Block a user