Merge pull request #7365 from continuedev/plan-mode-sys-prompt
feat: plan mode sys prompt
This commit is contained in:
commit
cfafdf8832
3 changed files with 116 additions and 2 deletions
|
|
@ -146,4 +146,105 @@ Rule 3: Third rule`;
|
|||
expect(result).not.toContain("IMPORTANT: You are running in headless mode");
|
||||
expect(result).not.toContain("Provide ONLY your final answer");
|
||||
});
|
||||
|
||||
it("should add JSON format instructions when format is json", async () => {
|
||||
const result = await constructSystemMessage(undefined, "json");
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).toContain(
|
||||
"IMPORTANT: You are operating in JSON output mode",
|
||||
);
|
||||
expect(result).toContain("Your final response MUST be valid JSON");
|
||||
expect(result).toContain("JSON.parse()");
|
||||
});
|
||||
|
||||
it("should add plan mode instructions when mode is plan", async () => {
|
||||
const result = await constructSystemMessage(
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
"plan",
|
||||
);
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).toContain(
|
||||
"which means that your goal is to help the user investigate their ideas",
|
||||
);
|
||||
expect(result).toContain("develop a plan before taking action");
|
||||
expect(result).toContain("read-only tools");
|
||||
expect(result).toContain(
|
||||
"should not attempt to circumvent them to write / delete / create files",
|
||||
);
|
||||
});
|
||||
|
||||
it("should not add plan mode instructions when mode is not plan", async () => {
|
||||
const result = await constructSystemMessage(
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
"normal",
|
||||
);
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).not.toContain(
|
||||
"which means that your goal is to help the user investigate their ideas",
|
||||
);
|
||||
});
|
||||
|
||||
it("should not add plan mode instructions when mode is undefined", async () => {
|
||||
const result = await constructSystemMessage();
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).not.toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).not.toContain(
|
||||
"which means that your goal is to help the user investigate their ideas",
|
||||
);
|
||||
});
|
||||
|
||||
it("should include basic plan mode description", async () => {
|
||||
const result = await constructSystemMessage(
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
"plan",
|
||||
);
|
||||
|
||||
expect(result).toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).toContain("read-only tools");
|
||||
expect(result).toContain("write / delete / create files");
|
||||
});
|
||||
|
||||
it("should combine plan mode with headless mode instructions", async () => {
|
||||
const result = await constructSystemMessage(
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
"plan",
|
||||
);
|
||||
|
||||
expect(result).toContain("IMPORTANT: You are running in headless mode");
|
||||
expect(result).toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).toContain(
|
||||
"which means that your goal is to help the user investigate their ideas",
|
||||
);
|
||||
});
|
||||
|
||||
it("should combine plan mode with JSON format instructions", async () => {
|
||||
const result = await constructSystemMessage(
|
||||
undefined,
|
||||
"json",
|
||||
false,
|
||||
"plan",
|
||||
);
|
||||
|
||||
expect(result).toContain(
|
||||
"IMPORTANT: You are operating in JSON output mode",
|
||||
);
|
||||
expect(result).toContain("PLAN MODE: You are operating in plan mode");
|
||||
expect(result).toContain(
|
||||
"which means that your goal is to help the user investigate their ideas",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import pkg from "ignore-walk";
|
|||
import { Minimatch } from "minimatch";
|
||||
|
||||
import { processPromptOrRule } from "./args.js";
|
||||
import { PermissionMode } from "./permissions/types.js";
|
||||
import { modeService } from "./services/ModeService.js";
|
||||
import { serviceContainer } from "./services/ServiceContainer.js";
|
||||
import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js";
|
||||
const { WalkerSync } = pkg;
|
||||
|
|
@ -116,16 +118,17 @@ async function getConfigYamlRules(): Promise<string[]> {
|
|||
|
||||
/**
|
||||
* Load and construct a comprehensive system message with base message and rules section
|
||||
* @param rulesSystemMessage - The rules system message from the assistant
|
||||
* @param additionalRules - Additional rules from --rule flags
|
||||
* @param format - Output format for headless mode
|
||||
* @param headless - Whether running in headless mode
|
||||
* @param mode - Current permission mode
|
||||
* @returns The comprehensive system message with base message and rules section
|
||||
*/
|
||||
export async function constructSystemMessage(
|
||||
additionalRules?: string[],
|
||||
format?: "json",
|
||||
headless?: boolean,
|
||||
mode?: PermissionMode,
|
||||
): Promise<string> {
|
||||
const agentFiles = ["AGENTS.md", "AGENT.md", "CLAUDE.md", "CODEX.md"];
|
||||
|
||||
|
|
@ -163,6 +166,9 @@ export async function constructSystemMessage(
|
|||
const configYamlRules = await getConfigYamlRules();
|
||||
processedRules.push(...configYamlRules);
|
||||
|
||||
// Get current mode if not provided
|
||||
const currentMode = mode ?? modeService.getCurrentMode();
|
||||
|
||||
// Construct the comprehensive system message
|
||||
let systemMessage = baseSystemMessage;
|
||||
|
||||
|
|
@ -185,6 +191,13 @@ Example response format:
|
|||
}`;
|
||||
}
|
||||
|
||||
// Add plan mode specific instructions if in plan mode
|
||||
if (currentMode === "plan") {
|
||||
systemMessage += `
|
||||
|
||||
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.`;
|
||||
}
|
||||
|
||||
// Add rules section if we have any rules or agent content
|
||||
if (agentContent || processedRules.length > 0) {
|
||||
systemMessage += '\n\n<context name="userRules">';
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "wt-nate-4",
|
||||
"name": "wt-plan-mode-sys-prompt",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue