fix(keyword-detector): always trigger ultrawork keywords
This commit is contained in:
@@ -106,7 +106,7 @@ describe("keyword-detector ralph-loop activation", () => {
|
|||||||
expect(output.parts[0]?.text).toContain("please ulw fix the flaky keyword tests")
|
expect(output.parts[0]?.text).toContain("please ulw fix the flaky keyword tests")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("#given question about ultrawork #when chat.message fires #then ralph-loop startLoop is not invoked", async () => {
|
test("#given question about ultrawork #when chat.message fires #then ralph-loop startLoop is invoked", async () => {
|
||||||
// given
|
// given
|
||||||
setMainSession("main-session")
|
setMainSession("main-session")
|
||||||
const startLoopCalls: StartLoopCall[] = []
|
const startLoopCalls: StartLoopCall[] = []
|
||||||
@@ -121,8 +121,9 @@ describe("keyword-detector ralph-loop activation", () => {
|
|||||||
await hook["chat.message"]({ sessionID: "main-session", agent: "sisyphus" }, output)
|
await hook["chat.message"]({ sessionID: "main-session", agent: "sisyphus" }, output)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startLoopCalls).toHaveLength(0)
|
expect(startLoopCalls).toHaveLength(1)
|
||||||
expect(output.parts[0]?.text).toBe("what is ultrawork?")
|
expect(startLoopCalls[0].prompt).toBe("what is ?")
|
||||||
|
expect(output.parts[0]?.text).toContain("what is ultrawork?")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("#given non-ulw message #when chat.message fires #then ralph-loop startLoop is not invoked", async () => {
|
test("#given non-ulw message #when chat.message fires #then ralph-loop startLoop is not invoked", async () => {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { parseRalphLoopArguments } from "../ralph-loop/command-arguments"
|
|||||||
|
|
||||||
const ULTRAWORK_LONGHAND_PATTERN = /\bultrawork\b/i
|
const ULTRAWORK_LONGHAND_PATTERN = /\bultrawork\b/i
|
||||||
const ULW_SHORTHAND_PATTERN = /\bulw\b/i
|
const ULW_SHORTHAND_PATTERN = /\bulw\b/i
|
||||||
const LEADING_ULTRAWORK_PATTERN = /^\s*(ultrawork|ulw)\b/i
|
|
||||||
const GREETING_PREFIX_ULTRAWORK_PATTERN = /^\s*(?:hi|hello|hey|hiya|greetings)(?:\s+there)?(?:[!,.:;-]+\s*|\s+)(ultrawork|ulw)\b/i
|
const GREETING_PREFIX_ULTRAWORK_PATTERN = /^\s*(?:hi|hello|hey|hiya|greetings)(?:\s+there)?(?:[!,.:;-]+\s*|\s+)(ultrawork|ulw)\b/i
|
||||||
|
|
||||||
function normalizeUltraworkTask(taskText: string): string {
|
function normalizeUltraworkTask(taskText: string): string {
|
||||||
@@ -38,12 +37,6 @@ function extractUltraworkTask(cleanText: string): string {
|
|||||||
return normalizeUltraworkTask(cleanText.replace(ULTRAWORK_LONGHAND_PATTERN, " "))
|
return normalizeUltraworkTask(cleanText.replace(ULTRAWORK_LONGHAND_PATTERN, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldAllowUltraworkKeyword(cleanText: string): boolean {
|
|
||||||
return ULW_SHORTHAND_PATTERN.test(cleanText)
|
|
||||||
|| LEADING_ULTRAWORK_PATTERN.test(cleanText)
|
|
||||||
|| GREETING_PREFIX_ULTRAWORK_PATTERN.test(cleanText)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createKeywordDetectorHook(
|
export function createKeywordDetectorHook(
|
||||||
ctx: PluginInput,
|
ctx: PluginInput,
|
||||||
_collector?: ContextCollector,
|
_collector?: ContextCollector,
|
||||||
@@ -99,16 +92,6 @@ export function createKeywordDetectorHook(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldAllowUltraworkKeyword(cleanText)) {
|
|
||||||
const preFilterCount = detectedKeywords.length
|
|
||||||
detectedKeywords = detectedKeywords.filter((k) => k.type !== "ultrawork")
|
|
||||||
if (preFilterCount > detectedKeywords.length) {
|
|
||||||
log(`[keyword-detector] Filtered disallowed ultrawork keyword`, {
|
|
||||||
sessionID: input.sessionID,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (detectedKeywords.length === 0) {
|
if (detectedKeywords.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ describe("keyword-detector ultrawork edge trigger", () => {
|
|||||||
expect(output.parts[0]?.text).toContain("please ulw fix the flaky keyword tests")
|
expect(output.parts[0]?.text).toContain("please ulw fix the flaky keyword tests")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("#given trailing ultrawork reference without punctuation #when chat.message fires #then ultrawork stays disabled", async () => {
|
test("#given trailing ultrawork reference without punctuation #when chat.message fires #then ultrawork still activates", async () => {
|
||||||
// given
|
// given
|
||||||
const toastCalls: string[] = []
|
const toastCalls: string[] = []
|
||||||
const startLoopCalls: StartLoopCall[] = []
|
const startLoopCalls: StartLoopCall[] = []
|
||||||
@@ -150,8 +150,9 @@ describe("keyword-detector ultrawork edge trigger", () => {
|
|||||||
await hook["chat.message"]({ sessionID: "main-session", agent: "sisyphus" }, output)
|
await hook["chat.message"]({ sessionID: "main-session", agent: "sisyphus" }, output)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(toastCalls).not.toContain("Ultrawork Mode Activated")
|
expect(toastCalls).toContain("Ultrawork Mode Activated")
|
||||||
expect(startLoopCalls).toHaveLength(0)
|
expect(startLoopCalls).toHaveLength(1)
|
||||||
expect(output.parts[0]?.text).toBe("what is ultrawork")
|
expect(startLoopCalls[0]?.prompt).toBe("what is")
|
||||||
|
expect(output.parts[0]?.text).toContain("what is ultrawork")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user