Skip to content

Commit 49555ca

Browse files
fix(test): escape regex special characters in momus test file path
Escape regex special characters when building RegExp from file path in momus.test.ts. The `.` characters in ".sisyphus/plans/plan.md" were matching any character instead of literal dots. Added escapeRegExp() helper and applied it when constructing the regex pattern. All tests pass. Co-Authored-By: Sisyphus <[email protected]>
1 parent d9e82ca commit 49555ca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/agents/momus.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { describe, test, expect } from "bun:test"
22
import { MOMUS_SYSTEM_PROMPT } from "./momus"
33

4+
function escapeRegExp(value: string) {
5+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
6+
}
7+
48
describe("MOMUS_SYSTEM_PROMPT policy requirements", () => {
59
test("should treat SYSTEM DIRECTIVE as ignorable/stripped", () => {
610
// #given
@@ -30,7 +34,10 @@ describe("MOMUS_SYSTEM_PROMPT policy requirements", () => {
3034
// #when / #then
3135
// In RED phase, this will FAIL because current prompt explicitly lists this as INVALID
3236
const invalidExample = "Please review .sisyphus/plans/plan.md"
33-
const rejectionTeaching = new RegExp(`reject.*${invalidExample}`, "i")
37+
const rejectionTeaching = new RegExp(
38+
`reject.*${escapeRegExp(invalidExample)}`,
39+
"i",
40+
)
3441

3542
// We want the prompt to NOT reject this anymore.
3643
// If it's still in the "INVALID" list, this test should fail.

0 commit comments

Comments
 (0)