Files
locode/src/tools/exitPlanMode.ts
T
kimandClaude f347c150a4 v0.6.0: sub-agent orchestration, plan mode, memory, and the Claude-Code feature gap
Closes the gap to Claude Code across four upgrade rounds (all verified
green: typecheck, 388 tests, build 313 KB).

Sub-agent orchestration:
- Resumable sub-agents (send_message) + MaxIterations "continue" path
- Configurable multi-depth sub-agent nesting
- Parallel fan-out for pure agent/agent__* batches, each writable delegation
  in its own throwaway git worktree (no file collisions)
- Named specialist fleet: explore, code-reviewer, planner, debugger,
  test-writer (read-only types skip worktree isolation)
- Named teammates: agent tool `name` arg + list_teammates + send_message
  by name (synchronous, addressable handle — not true async background)

Plan mode:
- True in-turn pause/resume on approval (no synthetic proceed turn)
- exit_plan_mode tool + side-by-side diff rendering (/diff)

Persistent memory:
- Typed file-per-fact memory under config dir, index folded into the
  system prompt (bounded), memory + memory_write tools, /memory command

Toolset + UI:
- multi_edit, notebook_edit, web_search/web_fetch, workflow orchestration
  primitive (agent/parallel/pipeline/phase/log + worktree isolation +
  best-effort structured output with recursive schema validation)
- Structured task system (task_create/list/get/update with dependency
  graph + ownership) replacing flat todo_write
- Cron/scheduled tasks (cron_create/list/delete, schedule_wakeup) with
  durable persistence and idle-gated ticking
- Interactive worktree session (enter_worktree/exit_worktree) with a
  live-cwd UI switch that survives /model changes
- AskUserQuestion tool + QuestionPrompt UI
- Permission rule granularity + user/project settings merge
- Color diffs, sub-agent activity panel, /undo, dashboard refinements

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-16 11:35:05 +09:00

44 lines
2.3 KiB
TypeScript

import { z } from "zod";
import type { ToolDef } from "./types.js";
const schema = z.object({
plan: z
.string()
.describe(
"The full implementation plan in prose: the files you would change, the approach for each, and the key edits. " +
"Be concrete and actionable so the user can review it at a glance.",
),
});
/** The structured way to exit plan mode: the model calls this once it has finished researching and
* has a concrete plan, instead of presenting the plan as a final prose message. The handler shows
* the plan to the user via the same Approve/Reject prompt the prose path uses (see maybePresentPlan
* in agent/loop.ts); on approval plan mode ends and the model proceeds to implement in the same
* turn, on rejection it stays in plan mode and can refine. The prose path remains as a fallback for
* models that present a plan without calling this tool. Non-mutating: it changes permission mode, not
* the filesystem, so it passes the plan-mode mutating-tool gate. Only callable in plan mode — the
* ctx callback is withheld otherwise, so a call at the wrong time returns a clear error. */
export const exitPlanModeTool: ToolDef<z.infer<typeof schema>> = {
name: "exit_plan_mode",
description:
"Exit plan mode by presenting your implementation plan for the user's approval. Call this once you've " +
"finished researching and have a concrete plan (which files you'd change and how). On approval, plan mode " +
"ends and you implement the plan in this same turn. On rejection, stay in plan mode, refine the plan (explore " +
"more if needed), and call exit_plan_mode again. Only available in plan mode — don't call it otherwise.",
schema,
mutating: false,
handler: async (args, ctx) => {
if (!ctx.exitPlanMode) {
return { error: "exit_plan_mode is only available while plan mode is active." };
}
const { approved } = await ctx.exitPlanMode(args.plan);
if (approved) {
return { result: "Plan approved. Plan mode is now off — proceed to implement the plan now." };
}
return {
result:
"The user rejected the plan. Stay in plan mode, refine it (explore more if needed), and call " +
"exit_plan_mode again when ready. Do not call any mutating tool yet.",
};
},
};