refactor(deps): restructured codebase to use centralized pi-utils package
- Created new @oh-my-pi/pi-utils workspace package with shared utilities for logging, process management, stream handling, and temporary directory management. - Migrated all packages to use centralized logger from @oh-my-pi/pi-utils instead of local winston implementations. - Replaced custom process spawning and stream reading implementations with standardized cspawn and readLines utilities across all modules. - Converted synchronous file operations and process spawning to async patterns using Bun shell syntax and fs/promises. - Added streaming edit abort functionality with configurable setting to abort on patch preview failures. - Updated test framework from vitest to bun:test across all test suites.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { describe, expect, it, vi } from "bun:test";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { createTempDirSync } from "@oh-my-pi/pi-utils";
|
||||
import * as pythonExecutor from "../../src/core/python-executor";
|
||||
import type { ToolSession } from "../../src/core/tools/index";
|
||||
import { PythonTool } from "../../src/core/tools/python";
|
||||
@@ -30,7 +28,7 @@ function createSession(cwd: string): ToolSession {
|
||||
|
||||
describe("python tool execution", () => {
|
||||
it("passes kernel options from settings and args", async () => {
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "python-tool-"));
|
||||
const tempDir = createTempDirSync("@python-tool-");
|
||||
const executeSpy = vi.spyOn(pythonExecutor, "executePython").mockResolvedValue({
|
||||
output: "ok",
|
||||
exitCode: 0,
|
||||
@@ -40,10 +38,10 @@ describe("python tool execution", () => {
|
||||
stdinRequested: false,
|
||||
});
|
||||
|
||||
const tool = new PythonTool(createSession(tempDir));
|
||||
const tool = new PythonTool(createSession(tempDir.path));
|
||||
const result = await tool.execute(
|
||||
"call-id",
|
||||
{ code: "print('hi')", timeout: 5, workdir: tempDir, reset: true },
|
||||
{ code: "print('hi')", timeout: 5, workdir: tempDir.path, reset: true },
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
@@ -52,9 +50,9 @@ describe("python tool execution", () => {
|
||||
expect(executeSpy).toHaveBeenCalledWith(
|
||||
"print('hi')",
|
||||
expect.objectContaining({
|
||||
cwd: tempDir,
|
||||
cwd: tempDir.path,
|
||||
timeout: 5000,
|
||||
sessionId: `session:session-file:workdir:${tempDir}`,
|
||||
sessionId: `session:session-file:workdir:${tempDir.path}`,
|
||||
kernelMode: "per-call",
|
||||
reset: true,
|
||||
}),
|
||||
@@ -63,6 +61,6 @@ describe("python tool execution", () => {
|
||||
expect(text).toBe("ok");
|
||||
|
||||
executeSpy.mockRestore();
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
tempDir.remove();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user