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>
This commit is contained in:
abel533
2026-04-05 13:16:55 +08:00
co-authored by Copilot
parent 12a443c9a9
commit 9f4023bdf0
57 changed files with 558 additions and 217 deletions
@@ -1,13 +1,13 @@
package com.claudecode.command.impl;
import com.claudecode.command.CommandContext;
import com.claudecode.command.SlashCommand;
import com.claudecode.command.BaseSlashCommand;
import com.claudecode.console.AnsiStyle;
/**
* /theme 命令 —— 切换主题(dark/light/auto)。
*/
public class ThemeCommand implements SlashCommand {
public class ThemeCommand extends BaseSlashCommand {
@Override
public String name() { return "theme"; }
@@ -17,15 +17,15 @@ public class ThemeCommand implements SlashCommand {
@Override
public String execute(String args, CommandContext context) {
if (context.agentLoop() == null) {
return AnsiStyle.red(" ✗ No active session");
if (requireAgentLoop(context) == null) {
return noSession();
}
var toolCtx = context.agentLoop().getToolContext();
var toolCtx = toolCtx(context);
String current = (String) toolCtx.get("THEME");
if (current == null) current = "dark";
String trimmed = (args == null) ? "" : args.trim().toLowerCase();
String trimmed = args(args).toLowerCase();
if (trimmed.isEmpty()) {
return "\n" + AnsiStyle.bold(" 🎨 Theme Settings\n")