refactor(coding-agent/core): migrated tool implementations from factory functions to class-based architecture

- Converted all tool implementations from factory functions to class-based architecture.
- Updated SDK exports to expose tool classes instead of create*Tool factory functions.
- Refactored tool instantiation patterns across all built-in tools and test files.
- Added proper TypeScript typing with AgentToolResult and AgentToolUpdateCallback interfaces.
This commit is contained in:
can1357
2026-01-19 08:40:27 +01:00
parent a3ef35d83e
commit fa2261002d
65 changed files with 4804 additions and 4391 deletions
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, it, vi } from "bun:test";
import * as pythonExecutor from "../../src/core/python-executor";
import { createTools, type ToolSession } from "../../src/core/tools/index";
import { createPythonTool } from "../../src/core/tools/python";
import { PythonTool } from "../../src/core/tools/python";
let previousSkipCheck: string | undefined;
@@ -46,7 +46,7 @@ function createSettings(toolMode: "ipy-only" | "bash-only" | "both") {
describe("python tool schema", () => {
it("exposes expected parameters", () => {
const tool = createPythonTool(createSession());
const tool = new PythonTool(createSession());
const schema = tool.parameters as {
type: string;
properties: Record<string, { type: string; description?: string }>;
@@ -74,7 +74,7 @@ describe("python tool docs template", () => {
];
const spy = vi.spyOn(pythonExecutor, "getPreludeDocs").mockReturnValue(docs);
const tool = createPythonTool(createSession());
const tool = new PythonTool(createSession());
expect(tool.description).toContain("### File I/O");
expect(tool.description).toContain("read(path)");
@@ -86,7 +86,7 @@ describe("python tool docs template", () => {
it("renders fallback when docs are unavailable", () => {
const spy = vi.spyOn(pythonExecutor, "getPreludeDocs").mockReturnValue([]);
const tool = createPythonTool(createSession());
const tool = new PythonTool(createSession());
expect(tool.description).toContain("Documentation unavailable — Python kernel failed to start");