Merge pull request #1698 from Luodian/fix/merge-skill-into-slashcommand
refactor: merge slashcommand behavior into skill tool to reduce prompt size
This commit is contained in:
@@ -43,13 +43,13 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
}
|
||||
}
|
||||
|
||||
if (hooks.ralphLoop && input.tool === "slashcommand") {
|
||||
const rawCommand = typeof output.args.command === "string" ? output.args.command : undefined
|
||||
const command = rawCommand?.replace(/^\//, "").toLowerCase()
|
||||
if (hooks.ralphLoop && input.tool === "skill") {
|
||||
const rawName = typeof output.args.name === "string" ? output.args.name : undefined
|
||||
const command = rawName?.replace(/^\//, "").toLowerCase()
|
||||
const sessionID = input.sessionID || getMainSessionID()
|
||||
|
||||
if (command === "ralph-loop" && sessionID) {
|
||||
const rawArgs = rawCommand?.replace(/^\/?(ralph-loop)\s*/i, "") || ""
|
||||
const rawArgs = rawName?.replace(/^\/?(ralph-loop)\s*/i, "") || ""
|
||||
const taskMatch = rawArgs.match(/^["'](.+?)["']/)
|
||||
const prompt =
|
||||
taskMatch?.[1] ||
|
||||
@@ -66,7 +66,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
} else if (command === "cancel-ralph" && sessionID) {
|
||||
hooks.ralphLoop.cancelLoop(sessionID)
|
||||
} else if (command === "ulw-loop" && sessionID) {
|
||||
const rawArgs = rawCommand?.replace(/^\/?(ulw-loop)\s*/i, "") || ""
|
||||
const rawArgs = rawName?.replace(/^\/?(ulw-loop)\s*/i, "") || ""
|
||||
const taskMatch = rawArgs.match(/^["'](.+?)["']/)
|
||||
const prompt =
|
||||
taskMatch?.[1] ||
|
||||
@@ -84,9 +84,9 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
}
|
||||
}
|
||||
|
||||
if (input.tool === "slashcommand") {
|
||||
const rawCommand = typeof output.args.command === "string" ? output.args.command : undefined
|
||||
const command = rawCommand?.replace(/^\//, "").toLowerCase()
|
||||
if (input.tool === "skill") {
|
||||
const rawName = typeof output.args.name === "string" ? output.args.name : undefined
|
||||
const command = rawName?.replace(/^\//, "").toLowerCase()
|
||||
const sessionID = input.sessionID || getMainSessionID()
|
||||
|
||||
if (command === "stop-continuation" && sessionID) {
|
||||
|
||||
@@ -11,9 +11,8 @@ import {
|
||||
createBackgroundTools,
|
||||
createCallOmoAgent,
|
||||
createLookAt,
|
||||
createSkillTool,
|
||||
createSkillMcpTool,
|
||||
createSlashcommandTool,
|
||||
createSkillTool,
|
||||
createGrepTools,
|
||||
createGlobTools,
|
||||
createAstGrepTools,
|
||||
@@ -89,14 +88,6 @@ export function createToolRegistry(args: {
|
||||
|
||||
const getSessionIDForMcp = (): string => getMainSessionID() || ""
|
||||
|
||||
const skillTool = createSkillTool({
|
||||
skills: skillContext.mergedSkills,
|
||||
mcpManager: managers.skillMcpManager,
|
||||
getSessionID: getSessionIDForMcp,
|
||||
gitMasterConfig: pluginConfig.git_master,
|
||||
disabledSkills: skillContext.disabledSkills,
|
||||
})
|
||||
|
||||
const skillMcpTool = createSkillMcpTool({
|
||||
manager: managers.skillMcpManager,
|
||||
getLoadedSkills: () => skillContext.mergedSkills,
|
||||
@@ -104,9 +95,12 @@ export function createToolRegistry(args: {
|
||||
})
|
||||
|
||||
const commands = discoverCommandsSync(ctx.directory)
|
||||
const slashcommandTool = createSlashcommandTool({
|
||||
const skillTool = createSkillTool({
|
||||
commands,
|
||||
skills: skillContext.mergedSkills,
|
||||
mcpManager: managers.skillMcpManager,
|
||||
getSessionID: getSessionIDForMcp,
|
||||
gitMasterConfig: pluginConfig.git_master,
|
||||
})
|
||||
|
||||
const taskSystemEnabled = pluginConfig.experimental?.task_system ?? false
|
||||
@@ -134,9 +128,8 @@ export function createToolRegistry(args: {
|
||||
call_omo_agent: callOmoAgent,
|
||||
...(lookAt ? { look_at: lookAt } : {}),
|
||||
task: delegateTask,
|
||||
skill: skillTool,
|
||||
skill_mcp: skillMcpTool,
|
||||
slashcommand: slashcommandTool,
|
||||
skill: skillTool,
|
||||
interactive_bash,
|
||||
...taskToolsRecord,
|
||||
...hashlineToolsRecord,
|
||||
|
||||
Reference in New Issue
Block a user