Changesets · Branches · Tags · Compare
| Changeset | dc523ee971e7f498c97aa1b34fd33817e39f004f076ad429b95e9fad4272f72c |
|---|---|
| Author | Nate <sestinj@gmail.com> · 2025-08-23 12:19 -07:00 |
| Committer | Nate <sestinj@gmail.com> · 2025-08-23 12:19 -07:00 |
| Parents | 2da2f5ebd951 |
3 files changed
modified extensions/cli/package.json +1 −1
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | "test:e2e": "vitest run --config vitest.e2e.config.ts", |
| 16 | 16 | "test:smoke": "node smoke-test.mjs", |
| 17 | 17 | "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", | |
| 19 | 19 | "build:validate": "node validate-aliases.mjs", |
| 20 | 20 | "build:bundle": "node build.mjs", |
| 21 | 21 | "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 @@ | ||
| 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("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 | + }); | |
| 149 | 209 | }); |
modified extensions/cli/src/systemMessage.ts +14 −1
| @@ -6,6 +6,8 @@ | ||
| 6 | 6 | import { Minimatch } from "minimatch"; |
| 7 | 7 | |
| 8 | 8 | import { processRule } 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">'; |