fix(ulw-loop): read loop task from user_message
Preserve the actual /ulw-loop task text from the skill tool payload instead of falling back to the default prompt when command arguments are passed separately. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -11,6 +11,16 @@ import { readState, writeState } from "../hooks/ralph-loop/storage"
|
||||
|
||||
import type { CreatedHooks } from "../create-hooks"
|
||||
|
||||
function getLoopCommandArguments(args: Record<string, unknown>, command: "ralph-loop" | "ulw-loop"): string {
|
||||
const rawUserMessage = typeof args.user_message === "string" ? args.user_message.trim() : ""
|
||||
if (rawUserMessage) {
|
||||
return rawUserMessage
|
||||
}
|
||||
|
||||
const rawName = typeof args.name === "string" ? args.name : ""
|
||||
return rawName.replace(new RegExp(`^/?(${command})\\s*`, "i"), "")
|
||||
}
|
||||
|
||||
export function createToolExecuteBeforeHandler(args: {
|
||||
ctx: PluginContext
|
||||
hooks: CreatedHooks
|
||||
@@ -137,7 +147,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
const sessionID = input.sessionID || getMainSessionID()
|
||||
|
||||
if (command === "ralph-loop" && sessionID) {
|
||||
const rawArgs = rawName?.replace(/^\/?(ralph-loop)\s*/i, "") || ""
|
||||
const rawArgs = getLoopCommandArguments(output.args, "ralph-loop")
|
||||
const parsedArguments = parseRalphLoopArguments(rawArgs)
|
||||
|
||||
hooks.ralphLoop.startLoop(sessionID, parsedArguments.prompt, {
|
||||
@@ -148,7 +158,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
} else if (command === "cancel-ralph" && sessionID) {
|
||||
hooks.ralphLoop.cancelLoop(sessionID)
|
||||
} else if (command === "ulw-loop" && sessionID) {
|
||||
const rawArgs = rawName?.replace(/^\/?(ulw-loop)\s*/i, "") || ""
|
||||
const rawArgs = getLoopCommandArguments(output.args, "ulw-loop")
|
||||
const parsedArguments = parseRalphLoopArguments(rawArgs)
|
||||
|
||||
hooks.ralphLoop.startLoop(sessionID, parsedArguments.prompt, {
|
||||
|
||||
Reference in New Issue
Block a user