如何构建从0到1的ClaudeAgent任务系统规划与协调策略?

摘要:多个任务之间有依赖关系怎么搞? Java实现代码 public class TaskSystem {配置 private static final Path WORKDIR = Paths.get(System.getPropert
多个任务之间有依赖关系怎么搞? Java实现代码 public class TaskSystem { // --- 配置 --- private static final Path WORKDIR = Paths.get(System.getProperty("user.dir")); private static final Path TASKS_DIR = WORKDIR.resolve(".tasks"); // 任务存储目录 private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); // --- 工具枚举--- public enum ToolType { BASH("bash", "Run a shell command."), READ_FILE("read_file", "Read file contents."), WRITE_FILE("write_file", "Write content to file."), EDIT_FILE("edit_file", "Replace exact text in file."), TASK_CREATE("task_create", "Create a new task."), // 新增:创建任务 TASK_GET("task_get", "Get full details of a task by ID."), // 新增:获取任务详情 TASK_UPDATE("task_update", "Update a task's status or dependencies."), // 新增:更新任务 TASK_LIST("task_list", "List all tasks with status summary."); // 新增:列出任务 public final String name; public final String description; ToolType(String name, String description) { this.name = name; this.description = description; } } // ... 省略相同的 ToolExecutor 接口 // --- 任务管理器 --- static class TaskManager { private final Path tasksDir; private int nextId = 1; public TaskManager(Path tasksDir) throws IOException { this.tasksDir = tasksDir; Files.createDirectories(tasksDir); this.nextId = getMaxId() + 1; // 自动计算下一个ID } private int getMaxId() { // 扫描已有任务文件,找到最大ID try { return Files.list(tasksDir) .filter(p -> p.getFileName().toString().startsWith("task_")) .map(p -> { try { String name = p.getFileName().toString(); return Integer.parseInt(name.substring(5, name.length() - 5)); // task_xxx.json } catch (NumberFormatE
阅读全文