Elffuss BraidHub

kikocis/continue public

Merge pull request #7365 from continuedev/plan-mode-sys-prompt

feat: plan mode sys prompt
Changeset4e263ad457a75e70009ab8f75dfeecb4846c13d8ed19ebce4d15df23fd9cfeee
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-08-23 12:51 -07:00
CommitterGitHub <noreply@github.com> · 2025-08-23 12:51 -07:00
Parents8eb3ae7b8d16, ea37f8381332

Browse the files at this changeset

3 files changed

modified extensions/cli/src/systemMessage.test.ts +101 −0
@@ -146,4 +146,105 @@
146146 expect(result).not.toContain("IMPORTANT: You are running in headless mode");
147147 expect(result).not.toContain("Provide ONLY your final answer");
148148 });
149+
150+ it("should add JSON format instructions when format is json", async () => {
151+ const result = await constructSystemMessage(undefined, "json");
152+
153+ expect(result).toContain("You are an agent in the Continue CLI");
154+ expect(result).toContain(
155+ "IMPORTANT: You are operating in JSON output mode",
156+ );
157+ expect(result).toContain("Your final response MUST be valid JSON");
158+ expect(result).toContain("JSON.parse()");
159+ });
160+
161+ it("should add plan mode instructions when mode is plan", async () => {
162+ const result = await constructSystemMessage(
163+ undefined,
164+ undefined,
165+ false,
166+ "plan",
167+ );
168+
169+ expect(result).toContain("You are an agent in the Continue CLI");
170+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
171+ expect(result).toContain(
172+ "which means that your goal is to help the user investigate their ideas",
173+ );
174+ expect(result).toContain("develop a plan before taking action");
175+ expect(result).toContain("read-only tools");
176+ expect(result).toContain(
177+ "should not attempt to circumvent them to write / delete / create files",
178+ );
179+ });
180+
181+ it("should not add plan mode instructions when mode is not plan", async () => {
182+ const result = await constructSystemMessage(
183+ undefined,
184+ undefined,
185+ false,
186+ "normal",
187+ );
188+
189+ expect(result).toContain("You are an agent in the Continue CLI");
190+ expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
191+ expect(result).not.toContain(
192+ "which means that your goal is to help the user investigate their ideas",
193+ );
194+ });
195+
196+ it("should not add plan mode instructions when mode is undefined", async () => {
197+ const result = await constructSystemMessage();
198+
199+ expect(result).toContain("You are an agent in the Continue CLI");
200+ expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
201+ expect(result).not.toContain(
202+ "which means that your goal is to help the user investigate their ideas",
203+ );
204+ });
205+
206+ it("should include basic plan mode description", async () => {
207+ const result = await constructSystemMessage(
208+ undefined,
209+ undefined,
210+ false,
211+ "plan",
212+ );
213+
214+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
215+ expect(result).toContain("read-only tools");
216+ expect(result).toContain("write / delete / create files");
217+ });
218+
219+ it("should combine plan mode with headless mode instructions", async () => {
220+ const result = await constructSystemMessage(
221+ undefined,
222+ undefined,
223+ true,
224+ "plan",
225+ );
226+
227+ expect(result).toContain("IMPORTANT: You are running in headless mode");
228+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
229+ expect(result).toContain(
230+ "which means that your goal is to help the user investigate their ideas",
231+ );
232+ });
233+
234+ it("should combine plan mode with JSON format instructions", async () => {
235+ const result = await constructSystemMessage(
236+ undefined,
237+ "json",
238+ false,
239+ "plan",
240+ );
241+
242+ expect(result).toContain(
243+ "IMPORTANT: You are operating in JSON output mode",
244+ );
245+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
246+ expect(result).toContain(
247+ "which means that your goal is to help the user investigate their ideas",
248+ );
249+ });
149250 });
modified extensions/cli/src/systemMessage.ts +14 −1
@@ -6,6 +6,8 @@
66 import { Minimatch } from "minimatch";
77
88 import { processPromptOrRule } from "./args.js";
9+import { PermissionMode } from "./permissions/types.js";
10+import { modeService } from "./services/ModeService.js";
911 import { serviceContainer } from "./services/ServiceContainer.js";
1012 import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js";
1113 const { WalkerSync } = pkg;
@@ -116,16 +118,17 @@
116118
117119 /**
118120 * Load and construct a comprehensive system message with base message and rules section
119- * @param rulesSystemMessage - The rules system message from the assistant
120121 * @param additionalRules - Additional rules from --rule flags
121122 * @param format - Output format for headless mode
122123 * @param headless - Whether running in headless mode
124+ * @param mode - Current permission mode
123125 * @returns The comprehensive system message with base message and rules section
124126 */
125127 export async function constructSystemMessage(
126128 additionalRules?: string[],
127129 format?: "json",
128130 headless?: boolean,
131+ mode?: PermissionMode,
129132 ): Promise<string> {
130133 const agentFiles = ["AGENTS.md", "AGENT.md", "CLAUDE.md", "CODEX.md"];
131134
@@ -163,6 +166,9 @@
163166 const configYamlRules = await getConfigYamlRules();
164167 processedRules.push(...configYamlRules);
165168
169+ // Get current mode if not provided
170+ const currentMode = mode ?? modeService.getCurrentMode();
171+
166172 // Construct the comprehensive system message
167173 let systemMessage = baseSystemMessage;
168174
@@ -185,6 +191,13 @@
185191 }`;
186192 }
187193
194+ // Add plan mode specific instructions if in plan mode
195+ if (currentMode === "plan") {
196+ systemMessage += `
197+
198+PLAN MODE: You are operating in plan mode, which means that your goal is to help the user investigate their ideas and develop a plan before taking action. You only have access to read-only tools and should not attempt to circumvent them to write / delete / create files.`;
199+ }
200+
188201 // Add rules section if we have any rules or agent content
189202 if (agentContent || processedRules.length > 0) {
190203 systemMessage += '\n\n<context name="userRules">';
modified package-lock.json +1 −1
@@ -1,5 +1,5 @@
11 {
2- "name": "wt-nate-4",
2+ "name": "wt-plan-mode-sys-prompt",
33 "lockfileVersion": 3,
44 "requires": true,
55 "packages": {