feat: add /plan planning-mode instructions

This commit is contained in:
Vignesh Natarajan 2026-01-24 16:31:47 -08:00
parent 21445cfc0a
commit 1179c3a88f
2 changed files with 31 additions and 0 deletions

View File

@ -310,6 +310,16 @@ describe("buildAgentSystemPrompt", () => {
expect(prompt).toContain("/status shows Reasoning");
});
it("includes /plan mode instructions", () => {
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/clawd",
});
expect(prompt).toContain("## Plan Mode (/plan)");
expect(prompt).toContain("If the user message starts with /plan");
expect(prompt).toContain("plans/<timestamp>-<slug>/");
});
it("builds runtime line with agent and channel details", () => {
const line = buildRuntimeLine(
{

View File

@ -558,6 +558,27 @@ export function buildAgentSystemPrompt(params: {
);
}
// Plan mode is conversational but stateful: compile a messy goal into a structured artifact.
if (!isMinimal) {
lines.push(
"## Plan Mode (/plan)",
"If the user message starts with /plan, enter *planning mode*.",
"- Treat everything after /plan as the goal.",
"- Ask targeted follow-up questions (one at a time) to remove ambiguity.",
"- Persist state in the workspace so planning can resume without losing context.",
"",
"Artifacts:",
"- Create a directory plans/<timestamp>-<slug>/ in the workspace.",
"- Maintain plans/<id>/answers.json (incremental) and plans/<id>/plan.md (human-readable).",
"- Optionally create plans/<id>/plan.json (structured) when helpful.",
"",
"Rules:",
"- Be token-efficient: do not restate the entire plan on every turn; ask the next question.",
"- When enough information is collected, produce a crisp plan with milestones + next actions.",
"",
);
}
lines.push(
"## Runtime",
buildRuntimeLine(runtimeInfo, runtimeChannel, runtimeCapabilities, params.defaultThinkLevel),