{"version":3,"file":"steer-command.test.d.ts","sourceRoot":"","sources":["../../src/core/steer-command.test.ts"],"names":[],"mappings":"","sourcesContent":["import { describe, expect, it, vi } from \"vitest\";\nimport { parseSteerCommand, runSteerCommand, STEER_COMMAND_ACTIVE_WORK_REQUIRED } from \"./steer-command.js\";\n\ndescribe(\"steer-command\", () => {\n\tit(\"parses /steer messages\", () => {\n\t\texpect(parseSteerCommand(\"/steer keep the implementation bounded\")).toBe(\"keep the implementation bounded\");\n\t\texpect(parseSteerCommand(\"/steer    tighten the acceptance criteria   \")).toBe(\"tighten the acceptance criteria\");\n\t\texpect(parseSteerCommand(\"/steer\")).toBeUndefined();\n\t\texpect(parseSteerCommand(\"/btw not this one\")).toBeUndefined();\n\t});\n\n\tit(\"queues steering during streaming without forcing a new continuation\", async () => {\n\t\tconst steeringMessages: string[] = [];\n\t\tconst continueCurrentWork = vi.fn<() => Promise<void>>().mockResolvedValue(undefined);\n\n\t\tconst output = await runSteerCommand(\n\t\t\t{\n\t\t\t\tisStreaming: true,\n\t\t\t\tstate: { messages: [{ role: \"assistant\" }] },\n\t\t\t\tsteer: async (message) => {\n\t\t\t\t\tsteeringMessages.push(message);\n\t\t\t\t},\n\t\t\t\tcontinueCurrentWork,\n\t\t\t\tgetSteeringMessages: () => steeringMessages,\n\t\t\t},\n\t\t\t\"keep the task bounded\",\n\t\t);\n\n\t\texpect(steeringMessages).toEqual([\"keep the task bounded\"]);\n\t\texpect(continueCurrentWork).not.toHaveBeenCalled();\n\t\texpect(output).toContain(\"Queued steering for the active workstream.\");\n\t\texpect(output).toContain(\"Pending steering messages: 1.\");\n\t});\n\n\tit(\"resumes from the latest assistant turn when idle\", async () => {\n\t\tconst steeringMessages: string[] = [];\n\t\tconst continueCurrentWork = vi.fn<() => Promise<void>>().mockResolvedValue(undefined);\n\n\t\tconst output = await runSteerCommand(\n\t\t\t{\n\t\t\t\tisStreaming: false,\n\t\t\t\tstate: { messages: [{ role: \"user\" }, { role: \"assistant\" }] },\n\t\t\t\tsteer: async (message) => {\n\t\t\t\t\tsteeringMessages.push(message);\n\t\t\t\t},\n\t\t\t\tcontinueCurrentWork,\n\t\t\t\tgetSteeringMessages: () => steeringMessages,\n\t\t\t},\n\t\t\t\"re-check the last diff before editing\",\n\t\t);\n\n\t\texpect(steeringMessages).toEqual([\"re-check the last diff before editing\"]);\n\t\texpect(continueCurrentWork).toHaveBeenCalledTimes(1);\n\t\texpect(output).toContain(\n\t\t\t\"Submitted steering for the active workstream and resumed from the latest assistant turn.\",\n\t\t);\n\t\texpect(output).toContain(\"This is not live mid-thought interruption\");\n\t});\n\n\tit(\"rejects /steer when there is no active workstream to continue\", async () => {\n\t\tconst continueCurrentWork = vi.fn<() => Promise<void>>().mockResolvedValue(undefined);\n\t\tconst steer = vi.fn<(message: string) => Promise<void>>().mockResolvedValue(undefined);\n\n\t\tawait expect(\n\t\t\trunSteerCommand(\n\t\t\t\t{\n\t\t\t\t\tisStreaming: false,\n\t\t\t\t\tstate: { messages: [] },\n\t\t\t\t\tsteer,\n\t\t\t\t\tcontinueCurrentWork,\n\t\t\t\t\tgetSteeringMessages: () => [],\n\t\t\t\t},\n\t\t\t\t\"start doing the work now\",\n\t\t\t),\n\t\t).rejects.toThrow(STEER_COMMAND_ACTIVE_WORK_REQUIRED);\n\t\texpect(steer).not.toHaveBeenCalled();\n\t\texpect(continueCurrentWork).not.toHaveBeenCalled();\n\t});\n});\n"]}