|
| 1 | +/** Model-facing description contracts at the public Bash/process tool factory boundary. */ |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | +import { withMockedPlatform } from "../test-utils/vitest-spies.js"; |
| 4 | +import { createExecTool, createProcessTool } from "./bash-tools.js"; |
| 5 | + |
| 6 | +const execDefaults = { host: "gateway", security: "full", ask: "off" } as const; |
| 7 | +const execTool = createExecTool(execDefaults); |
| 8 | +const processTool = createProcessTool(); |
| 9 | + |
| 10 | +describe("tool descriptions", () => { |
| 11 | + it("adds automation follow-up guidance only when the scheduler is available", () => { |
| 12 | + const execWithCron = createExecTool({ ...execDefaults, hasCronTool: true }); |
| 13 | + const processWithCron = createProcessTool({ hasCronTool: true }); |
| 14 | + |
| 15 | + expect(execWithCron.description).toContain( |
| 16 | + "automatic completion wake when enabled and output/failure occurs; otherwise process confirms completion", |
| 17 | + ); |
| 18 | + expect(processWithCron.description).toContain("completion without auto-wake"); |
| 19 | + expect(processWithCron.description).toContain("write, send-keys, submit, paste, kill"); |
| 20 | + expect(execWithCron.description).toContain( |
| 21 | + "No sleep loops for reminders/follow-ups; use automations.", |
| 22 | + ); |
| 23 | + expect(processWithCron.description).toContain( |
| 24 | + "No polling as timer/reminder; scheduled follow-up uses automations.", |
| 25 | + ); |
| 26 | + expect(execTool.description).not.toContain("use cron instead"); |
| 27 | + expect(processTool.description).not.toContain("scheduled follow-ups"); |
| 28 | + expect(execTool.description).toContain("otherwise process confirms completion"); |
| 29 | + expect(processTool.description).toContain("completion without auto-wake"); |
| 30 | + expect(processTool.description).toContain("write, send-keys, submit, paste, kill"); |
| 31 | + }); |
| 32 | + |
| 33 | + it.each(["darwin", "linux", "win32"] as const)( |
| 34 | + "limits shell-quoting guidance to Unix hosts: %s", |
| 35 | + (platform) => { |
| 36 | + withMockedPlatform(platform, () => { |
| 37 | + expect( |
| 38 | + execTool.description.includes( |
| 39 | + "Quote arguments containing shell metacharacters, including URL query strings with `?` or `&`.", |
| 40 | + ), |
| 41 | + ).toBe(platform !== "win32"); |
| 42 | + }); |
| 43 | + }, |
| 44 | + ); |
| 45 | +}); |
0 commit comments