import type { ToolWithMetadata } from './types.js';
import { toolRegistry } from './registry.js';

// Shell 工具
import { bashTool } from './shell/index.js';

// 核心工具
import { toolSearchTool } from './tool-search.js';
import { todoReadTool, todoWriteTool } from './todo/index.js';

// Task 工具（Agent 子任务）
import { taskTool, agentOutputTool } from './task/index.js';

// Skill 工具
import { skillTool, skillSearchTool } from './skill/index.js';

// 文件系统工具
import {
  readFileTool,
  writeFileTool,
  editFileTool,
  multiEditTool,
  listDirTool,
  createDirectoryTool,
  searchFilesTool,
  grepContentTool,
  getFileInfoTool,
  moveFileTool,
  copyFileTool,
  deleteFileTool,
} from './filesystem/index.js';

// Web 工具
import { webSearchTool, webExtractTool } from './web/index.js';

// Git 工具
import {
  gitStatusTool,
  gitDiffTool,
  gitLogTool,
  gitBranchTool,
  gitAddTool,
  gitCommitTool,
  gitPushTool,
  gitPullTool,
  gitCheckoutTool,
  gitStashTool,
} from './git/index.js';

// RepoMap 工具
import { repoMapTool } from './repomap/index.js';

// 检查点工具
import {
  checkpointCreateTool,
  checkpointListTool,
  checkpointDiffTool,
  checkpointRestoreTool,
  undoTool,
} from './checkpoint/index.js';

// Plan 工具
import { planModeRespondTool } from './plan/index.js';

// 所有工具列表（用于注册）
const allToolsWithMetadata: ToolWithMetadata[] = [
  // 核心工具 (deferLoading: false)
  toolSearchTool,
  bashTool,
  todoReadTool,
  todoWriteTool,
  taskTool,
  agentOutputTool,

  // Skill 工具 (deferLoading: false)
  skillTool,
  skillSearchTool,

  // 文件系统工具 (deferLoading: true)
  readFileTool,
  writeFileTool,
  editFileTool,
  multiEditTool,
  listDirTool,
  createDirectoryTool,
  searchFilesTool,
  grepContentTool,
  getFileInfoTool,
  moveFileTool,
  copyFileTool,
  deleteFileTool,

  // Web 工具 (deferLoading: false)
  webSearchTool,
  webExtractTool,

  // Git 工具 (deferLoading: false)
  gitStatusTool,
  gitDiffTool,
  gitLogTool,
  gitBranchTool,
  gitAddTool,
  gitCommitTool,
  gitPushTool,
  gitPullTool,
  gitCheckoutTool,
  gitStashTool,

  // RepoMap 工具 (deferLoading: true)
  repoMapTool,

  // 检查点工具
  undoTool, // deferLoading: false - 常用命令
  checkpointCreateTool,
  checkpointListTool,
  checkpointDiffTool,
  checkpointRestoreTool,

  // Plan 工具 (deferLoading: true - 仅 Plan 模式)
  planModeRespondTool,
];

// 注册所有工具到 registry
toolRegistry.registerAll(allToolsWithMetadata);

// 导出
export { toolRegistry } from './registry.js';
export { toolSearchTool } from './tool-search.js';
export { todoManager } from './todo/index.js';
export { initTaskContext, updateTaskDescription } from './task/index.js';
export { updateSkillDescription } from './skill/index.js';
export type { ToolWithMetadata, ToolMetadata, ToolCategory, ToolSearchResult } from './types.js';
