Skip to content
Source
Sign inSign up
Open History to see the last commit

orchestrationInstructions.test.ts

85 lines3.5 KB

1import { assert, describe, it } from "@effect/vitest";
2​
3import {
4 T3_CODE_DEVICE_TOOL_INSTRUCTIONS,
5 T3_CODE_DEVICE_TOOL_INSTRUCTIONS_WITH_TOOL_SEARCH,
6 T3_CODE_ORCHESTRATION_INSTRUCTIONS,
7 t3AcpPromptWithInstructions,
8 t3OrchestrationPrompt,
9 t3OrchestrationSystemPrompt,
10} from "./orchestrationInstructions.ts";
11​
12describe("T3 device instructions", () => {
13 it("route device work through device_open and give Claude the line that loads the tools", () => {
14 for (const intent of ["`device_list`", "`device_open`", "`agent-device`", "ssh", "`hostId`"]) {
15 assert.include(T3_CODE_DEVICE_TOOL_INSTRUCTIONS, intent);
16 }
17 assert.notInclude(T3_CODE_DEVICE_TOOL_INSTRUCTIONS, "ToolSearch");
18 const loadLine =
19 " Load them with ToolSearch `select:mcp__t3-code__device_list,mcp__t3-code__device_open,mcp__t3-code__device_screenshot,mcp__t3-code__device_close`.";
20 assert.include(T3_CODE_DEVICE_TOOL_INSTRUCTIONS_WITH_TOOL_SEARCH, loadLine);
21 assert.equal(
22 T3_CODE_DEVICE_TOOL_INSTRUCTIONS_WITH_TOOL_SEARCH.replace(loadLine, ""),
23 T3_CODE_DEVICE_TOOL_INSTRUCTIONS,
24 );
25 });
26​
27 it("open the app before the returned command's snapshots, screenshots and input", () => {
28 assert.include(
29 T3_CODE_DEVICE_TOOL_INSTRUCTIONS,
30 "its snapshots, screenshots and input need `open <app>` first,",
31 );
32 });
33​
34 it("keep the failure rule from taking over or closing a session another thread holds", () => {
35 // agent-device's DEVICE_IN_USE advice is to rerun with the owner's --session or close it first.
36 assert.include(
37 T3_CODE_DEVICE_TOOL_INSTRUCTIONS,
38 "follow its advice once, but never reuse or close another session; if it still fails,",
39 );
40 });
41​
42 it("reach OpenCode and Cursor only when the session holds device access", () => {
43 assert.include(t3OrchestrationSystemPrompt(true, true), T3_CODE_DEVICE_TOOL_INSTRUCTIONS);
44 assert.notInclude(t3OrchestrationSystemPrompt(true, false), "## T3 Code devices");
45 assert.isUndefined(t3OrchestrationSystemPrompt(false, true));
46​
47 const firstRun = (hasDeviceTools: boolean) =>
48 t3OrchestrationPrompt({
49 prompt: "Check the login screen.",
50 hasT3Mcp: true,
51 hasDeviceTools,
52 orchestrationDelivered: false,
53 deviceInstructionsDelivered: false,
54 });
55 assert.include(firstRun(true), T3_CODE_DEVICE_TOOL_INSTRUCTIONS);
56 assert.notInclude(firstRun(false), "## T3 Code devices");
57​
58 const laterRun = (deviceInstructionsDelivered: boolean) =>
59 t3OrchestrationPrompt({
60 prompt: "Check the login screen.",
61 hasT3Mcp: true,
62 hasDeviceTools: true,
63 orchestrationDelivered: true,
64 deviceInstructionsDelivered,
65 });
66 assert.include(laterRun(false), T3_CODE_DEVICE_TOOL_INSTRUCTIONS);
67 assert.notInclude(laterRun(false), T3_CODE_ORCHESTRATION_INSTRUCTIONS.trim());
68 assert.equal(laterRun(true), "Check the login screen.");
69 });
70​
71 it("reach ACP agents again when device access changes mid-thread", () => {
72 const state = { interactionMode: "default", hasT3Mcp: true, hasDeviceTools: false } as const;
73 const withDevices = t3AcpPromptWithInstructions({
74 prompt: "Check the login screen.",
75 state: { ...state, hasDeviceTools: true },
76 previousState: state,
77 });
78 assert.include(withDevices, T3_CODE_DEVICE_TOOL_INSTRUCTIONS);
79 assert.equal(
80 t3AcpPromptWithInstructions({ prompt: "Again.", state, previousState: state }),
81 "Again.",
82 );
83 assert.notInclude(t3AcpPromptWithInstructions({ prompt: "Hi.", state }), "## T3 Code devices");
84 });
85});