Elffuss BraidHub

kikocis/continue public

feat: plan mode sys prompt
Changesetdc523ee971e7f498c97aa1b34fd33817e39f004f076ad429b95e9fad4272f72c
AuthorNate <sestinj@gmail.com> · 2025-08-23 12:19 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-23 12:19 -07:00
Parents2da2f5ebd951

Browse the files at this changeset

3 files changed

modified extensions/cli/package.json +1 −1
@@ -15,7 +15,7 @@
1515 "test:e2e": "vitest run --config vitest.e2e.config.ts",
1616 "test:smoke": "node smoke-test.mjs",
1717 "build:tsc": "tsc -p tsconfig.build.json",
18- "build:local-deps": "cd ../../packages/config-types && npm run build && cd ../config-yaml && npm run build && cd ../openai-adapters && npm run build",
18+ "build:local-deps": "cd ../../packages/config-types && npm i && npm run build && cd ../config-yaml && npm i && npm run build && cd ../fetch && npm i && npm run build && cd ../openai-adapters && npm i && npm run build",
1919 "build:validate": "node validate-aliases.mjs",
2020 "build:bundle": "node build.mjs",
2121 "build": "npm run build:local-deps && npm run build:validate && npm run build:bundle",
modified extensions/cli/src/systemMessage.test.ts +60 −0
@@ -146,4 +146,64 @@
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("IMPORTANT: You are operating in JSON output mode");
155+ expect(result).toContain("Your final response MUST be valid JSON");
156+ expect(result).toContain("JSON.parse()");
157+ });
158+
159+ it("should add plan mode instructions when mode is plan", async () => {
160+ const result = await constructSystemMessage(undefined, undefined, false, "plan");
161+
162+ expect(result).toContain("You are an agent in the Continue CLI");
163+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
164+ expect(result).toContain("which means that your goal is to help the user investigate their ideas");
165+ expect(result).toContain("develop a plan before taking action");
166+ expect(result).toContain("read-only tools");
167+ expect(result).toContain("should not attempt to circumvent them to write / delete / create files");
168+ });
169+
170+ it("should not add plan mode instructions when mode is not plan", async () => {
171+ const result = await constructSystemMessage(undefined, undefined, false, "normal");
172+
173+ expect(result).toContain("You are an agent in the Continue CLI");
174+ expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
175+ expect(result).not.toContain("which means that your goal is to help the user investigate their ideas");
176+ });
177+
178+ it("should not add plan mode instructions when mode is undefined", async () => {
179+ const result = await constructSystemMessage();
180+
181+ expect(result).toContain("You are an agent in the Continue CLI");
182+ expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
183+ expect(result).not.toContain("which means that your goal is to help the user investigate their ideas");
184+ });
185+
186+ it("should include basic plan mode description", async () => {
187+ const result = await constructSystemMessage(undefined, undefined, false, "plan");
188+
189+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
190+ expect(result).toContain("read-only tools");
191+ expect(result).toContain("write / delete / create files");
192+ });
193+
194+ it("should combine plan mode with headless mode instructions", async () => {
195+ const result = await constructSystemMessage(undefined, undefined, true, "plan");
196+
197+ expect(result).toContain("IMPORTANT: You are running in headless mode");
198+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
199+ expect(result).toContain("which means that your goal is to help the user investigate their ideas");
200+ });
201+
202+ it("should combine plan mode with JSON format instructions", async () => {
203+ const result = await constructSystemMessage(undefined, "json", false, "plan");
204+
205+ expect(result).toContain("IMPORTANT: You are operating in JSON output mode");
206+ expect(result).toContain("PLAN MODE: You are operating in plan mode");
207+ expect(result).toContain("which means that your goal is to help the user investigate their ideas");
208+ });
149209 });
modified extensions/cli/src/systemMessage.ts +14 −1
@@ -6,6 +6,8 @@
66 import { Minimatch } from "minimatch";
77
88 import { processRule } 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">';