Files
claude-code/src/main/java/com/claudecode/command/impl/PlanCommand.java
T
abel533andCopilot 9f4023bdf0 refactor: apply BaseSlashCommand to all 54 command implementations
- implements SlashCommand -> extends BaseSlashCommand (all 54 files)
- Replace CommandUtils.parseArgs/args null checks -> args(args)
- Replace agentLoop null checks -> requireAgentLoop(context)/noSession()
- Replace context.agentLoop().getToolContext() -> toolCtx(context)
- Replace CommandUtils.success/error/header/subtitle/warning/info -> instance methods
- Remove unused CommandUtils/AnsiStyle imports where applicable
- 87 tests passing, zero compilation errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 13:16:55 +08:00

49 lines
1.6 KiB
Java

package com.claudecode.command.impl;
import com.claudecode.command.CommandContext;
import com.claudecode.command.BaseSlashCommand;
import com.claudecode.permission.PermissionSettings;
import com.claudecode.permission.PermissionTypes.PermissionMode;
/**
* /plan 命令 —— 对应 claude-code/src/commands/plan/plan.tsx。
* <p>
* 切换计划模式开关。在计划模式下,AI只能分析不能修改。
*/
public class PlanCommand extends BaseSlashCommand {
private final PermissionSettings permissionSettings;
public PlanCommand(PermissionSettings permissionSettings) {
this.permissionSettings = permissionSettings;
}
@Override
public String name() {
return "plan";
}
@Override
public String description() {
return "Toggle plan mode (analysis only, no file modifications)";
}
@Override
public String execute(String args, CommandContext context) {
PermissionMode currentMode = permissionSettings.getCurrentMode();
if (currentMode == PermissionMode.PLAN) {
// Exit plan mode
permissionSettings.setCurrentMode(PermissionMode.DEFAULT);
return "📋 Exited plan mode. Normal permissions restored.\n" +
"All tools are now available.";
} else {
// Enter plan mode
permissionSettings.setCurrentMode(PermissionMode.PLAN);
return "📋 Entered plan mode.\n" +
"Only read-only tools are available. Use /plan again to exit.\n" +
"Or ask the AI to call EnterPlanMode for the full workflow.";
}
}
}