|
1 | 1 | import { assert, it } from "@effect/vitest"; |
2 | 2 | import { |
| 3 | + parseGoalCommand, |
3 | 4 | CheckpointScopeId, |
4 | 5 | ChatAttachmentId, |
5 | 6 | ChatFileAttachment, |
@@ -1083,6 +1084,18 @@ it.effect( |
1083 | 1084 | }, |
1084 | 1085 | { text: "/compact", attachments: [attachment], expected: "prompt" }, |
1085 | 1086 | { text: "/goal finish the work", attachments: [], expected: "goal" }, |
| 1087 | + { text: " /goal finish the work ", attachments: [], expected: "goal" }, |
| 1088 | + { |
| 1089 | + text: "/goal finish the work", |
| 1090 | + attachments: [], |
| 1091 | + expected: "goal", |
| 1092 | + driver: ProviderDriverKind.make("claudeAgent"), |
| 1093 | + }, |
| 1094 | + ...["/goal", "/goal edit", "/goal clear", "/goal pause", "/goal resume"].map((text) => ({ |
| 1095 | + text, |
| 1096 | + attachments: [], |
| 1097 | + expected: "control", |
| 1098 | + })), |
1086 | 1099 | { text: "/goal finish the work", attachments: [attachment], expected: "prompt" }, |
1087 | 1100 | { text: "Continue the work", attachments: [], expected: "prompt" }, |
1088 | 1101 | ] |
@@ -1163,14 +1176,23 @@ it.effect( |
1163 | 1176 | const prompt = prompts[0]; |
1164 | 1177 | if (prompt !== undefined) { |
1165 | 1178 | if ( |
1166 | | - testCase.expected !== "goal" && |
1167 | | - testCase.expected !== "command" && |
| 1179 | + testCase.expected !== "control" && |
1168 | 1180 | testCase.createdBy === "agent" && |
1169 | 1181 | testCase.senderThreadId !== undefined |
1170 | 1182 | ) { |
1171 | 1183 | assert.include(prompt.message.text, 'thread "thread:sender"'); |
1172 | 1184 | assert.include(prompt.message.text, "not a message from the human user"); |
1173 | | - assert.isTrue(prompt.message.text.endsWith(`\n\n${testCase.text}`)); |
| 1185 | + if (testCase.expected === "goal") { |
| 1186 | + const goal = parseGoalCommand(prompt.message); |
| 1187 | + assert.equal(goal?.type, "set"); |
| 1188 | + if (goal?.type === "set") |
| 1189 | + assert.isTrue(goal.objective.endsWith("\n\nfinish the work")); |
| 1190 | + } else if (testCase.expected === "command") { |
| 1191 | + assert.isTrue(prompt.message.text.startsWith("/compact [Message from")); |
| 1192 | + assert.isTrue(prompt.message.text.endsWith("\n\nkeep the tests")); |
| 1193 | + } else { |
| 1194 | + assert.isTrue(prompt.message.text.endsWith(`\n\n${testCase.text}`)); |
| 1195 | + } |
1174 | 1196 | } else { |
1175 | 1197 | assert.equal(prompt.message.text, testCase.text); |
1176 | 1198 | } |
|
0 commit comments