a2854ba768
Migrate 203 test files (356 call sites) from fs.rm/fs.rmSync to
removeWithRetries/removeSyncWithRetries to reduce EBUSY test failures
on Windows. removeWithRetries is now exported from @oh-my-pi/pi-utils.
The migration uses a regex-based approach that:
- Replaces fs.rm(path, { recursive, force }) → removeWithRetries(path)
- Replaces fs.rmSync(path, { recursive, force }) → removeSyncWithRetries(path)
- Replaces fs.rm(path) → removeWithRetries(path) (no options)
- Skips fs.rm/fs.rmSync inside template literals (bun --eval scripts)
- Adds imports to existing @oh-my-pi/pi-utils import or creates new one
- Removes unused fs imports where fs.rm was the only fs usage (4 files)
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
import * as fs from "node:fs/promises";
|
|
import * as os from "node:os";
|
|
import * as path from "node:path";
|
|
import { discoverAgents } from "@oh-my-pi/pi-coding-agent/task/discovery";
|
|
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
|
|
|
const OMP_AGENT_MD = [
|
|
"---",
|
|
"name: omp-test-agent",
|
|
"description: OMP-native test agent.",
|
|
"---",
|
|
"You are an OMP task agent.",
|
|
].join("\n");
|
|
|
|
const CLAUDE_AGENT_MD = [
|
|
"---",
|
|
"name: cc-test-agent",
|
|
"description: Test Claude Code agent.",
|
|
"tools: Read, Grep, Glob, Bash",
|
|
"model: sonnet",
|
|
"color: purple",
|
|
"---",
|
|
"You are a Claude Code custom subagent.",
|
|
].join("\n");
|
|
|
|
describe("discoverAgents", () => {
|
|
let tempHome: string;
|
|
let projectDir: string;
|
|
|
|
beforeEach(async () => {
|
|
tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "omp-task-agent-discovery-"));
|
|
projectDir = path.join(tempHome, "project");
|
|
await fs.mkdir(projectDir, { recursive: true });
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await removeWithRetries(tempHome);
|
|
});
|
|
|
|
test("loads OMP agents but skips Claude Code custom agents", async () => {
|
|
await fs.mkdir(path.join(projectDir, ".omp", "agents"), { recursive: true });
|
|
await fs.writeFile(path.join(projectDir, ".omp", "agents", "omp-test-agent.md"), OMP_AGENT_MD);
|
|
|
|
await fs.mkdir(path.join(tempHome, ".claude", "agents"), { recursive: true });
|
|
await fs.writeFile(path.join(tempHome, ".claude", "agents", "user-cc-test-agent.md"), CLAUDE_AGENT_MD);
|
|
await fs.mkdir(path.join(projectDir, ".claude", "agents"), { recursive: true });
|
|
await fs.writeFile(path.join(projectDir, ".claude", "agents", "project-cc-test-agent.md"), CLAUDE_AGENT_MD);
|
|
|
|
const { agents, projectAgentsDir } = await discoverAgents(projectDir, tempHome);
|
|
const names = agents.map(agent => agent.name);
|
|
|
|
expect(names).toContain("omp-test-agent");
|
|
expect(names).not.toContain("cc-test-agent");
|
|
expect(projectAgentsDir).toBe(path.join(projectDir, ".omp", "agents"));
|
|
});
|
|
});
|