Changesets · Branches · Tags · Compare
| Changeset | 4e263ad457a75e70009ab8f75dfeecb4846c13d8ed19ebce4d15df23fd9cfeee |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-08-23 12:51 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-08-23 12:51 -07:00 |
| Parents | 8eb3ae7b8d16, ea37f8381332 |
3 files changed
modified extensions/cli/src/systemMessage.test.ts +101 −0
| @@ -146,4 +146,105 @@ | ||
| 146 | 146 | expect(result).not.toContain("IMPORTANT: You are running in headless mode"); |
| 147 | 147 | expect(result).not.toContain("Provide ONLY your final answer"); |
| 148 | 148 | }); |
| 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 | + }); | |
| 149 | 250 | }); |
modified extensions/cli/src/systemMessage.ts +14 −1
| @@ -6,6 +6,8 @@ | ||
| 6 | 6 | import { Minimatch } from "minimatch"; |
| 7 | 7 | |
| 8 | 8 | import { processPromptOrRule } from "./args.js"; |
| 9 | +import { PermissionMode } from "./permissions/types.js"; | |
| 10 | +import { modeService } from "./services/ModeService.js"; | |
| 9 | 11 | import { serviceContainer } from "./services/ServiceContainer.js"; |
| 10 | 12 | import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js"; |
| 11 | 13 | const { WalkerSync } = pkg; |
| @@ -116,16 +118,17 @@ | ||
| 116 | 118 | |
| 117 | 119 | /** |
| 118 | 120 | * Load and construct a comprehensive system message with base message and rules section |
| 119 | - * @param rulesSystemMessage - The rules system message from the assistant | |
| 120 | 121 | * @param additionalRules - Additional rules from --rule flags |
| 121 | 122 | * @param format - Output format for headless mode |
| 122 | 123 | * @param headless - Whether running in headless mode |
| 124 | + * @param mode - Current permission mode | |
| 123 | 125 | * @returns The comprehensive system message with base message and rules section |
| 124 | 126 | */ |
| 125 | 127 | export async function constructSystemMessage( |
| 126 | 128 | additionalRules?: string[], |
| 127 | 129 | format?: "json", |
| 128 | 130 | headless?: boolean, |
| 131 | + mode?: PermissionMode, | |
| 129 | 132 | ): Promise<string> { |
| 130 | 133 | const agentFiles = ["AGENTS.md", "AGENT.md", "CLAUDE.md", "CODEX.md"]; |
| 131 | 134 | |
| @@ -163,6 +166,9 @@ | ||
| 163 | 166 | const configYamlRules = await getConfigYamlRules(); |
| 164 | 167 | processedRules.push(...configYamlRules); |
| 165 | 168 | |
| 169 | + // Get current mode if not provided | |
| 170 | + const currentMode = mode ?? modeService.getCurrentMode(); | |
| 171 | + | |
| 166 | 172 | // Construct the comprehensive system message |
| 167 | 173 | let systemMessage = baseSystemMessage; |
| 168 | 174 | |
| @@ -185,6 +191,13 @@ | ||
| 185 | 191 | }`; |
| 186 | 192 | } |
| 187 | 193 | |
| 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 | + | |
| 188 | 201 | // Add rules section if we have any rules or agent content |
| 189 | 202 | if (agentContent || processedRules.length > 0) { |
| 190 | 203 | systemMessage += '\n\n<context name="userRules">'; |
modified package-lock.json +1 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | { |
| 2 | - "name": "wt-nate-4", | |
| 2 | + "name": "wt-plan-mode-sys-prompt", | |
| 3 | 3 | "lockfileVersion": 3, |
| 4 | 4 | "requires": true, |
| 5 | 5 | "packages": { |