Files
oh-my-pi/packages/coding-agent/test/slash-commands/omfg.test.ts
T
can1357 9a5caba3a4 feat(modes): added OMFG mode with live draft panel and stream handling
- Added `/omfg <complaint>` command integration from slash registry to mode context and input handling.
- Added OMFG panel and controller for live draft streaming, up to three retries, and confirmed save flow.
- Added strict OMFG rule extraction and validation with JSON parsing, alias checks, and history-based repair.
- Fixed auto-thinking restore to preserve resolved effort instead of reverting to pending auto sessions.
2026-05-31 04:15:25 +02:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { executeBuiltinSlashCommand } from "@oh-my-pi/pi-coding-agent/slash-commands/builtin-registry";
function createRuntime() {
const handleOmfgCommand = vi.fn(async () => {});
const setText = vi.fn();
return {
handleOmfgCommand,
setText,
runtime: {
ctx: {
editor: { setText } as unknown as InteractiveModeContext["editor"],
handleOmfgCommand,
} as unknown as InteractiveModeContext,
handleBackgroundCommand: () => {},
},
};
}
describe("/omfg slash command", () => {
it("routes the full complaint through the interactive omfg handler", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand("/omfg This guy used any again....", harness.runtime);
expect(handled).toBe(true);
expect(harness.setText).toHaveBeenCalledWith("");
expect(harness.handleOmfgCommand).toHaveBeenCalledWith("This guy used any again....");
});
it("preserves the raw multi-word suffix after /omfg", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand(
"/omfg stop making unchecked casts in generated TypeScript",
harness.runtime,
);
expect(handled).toBe(true);
expect(harness.handleOmfgCommand).toHaveBeenCalledWith("stop making unchecked casts in generated TypeScript");
});
});