Skip to content

Commit ac4c543

Browse files
author
Yetibot
committed
build local yetibot helper tool into agent workspace for native-feeling tool calls
1 parent 678fd3c commit ac4c543

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

src/yetibot/core/commands/agent.clj

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,15 @@
372372
"'Yetibot' / user.email 'yetibot@yetibot.com', make a minimal change on a "
373373
"new branch, push to origin, and `gh pr create`.\n"
374374
"- Question: just answer it; clone only if the answer needs the code.\n\n"
375-
"Tools (shell): `gh` (authenticated), `git`, and `curl` (to query yetibot's runtime commands via the API).\n\n"
375+
"Tools (shell): `gh` (authenticated), `git`, and `./yetibot` (to run Yetibot commands directly).\n\n"
376376
"Introspecting and running Yetibot commands:\n"
377-
"You can query and execute Yetibot commands and aliases via Yetibot's HTTP API at `http://localhost:$YETIBOT_PORT/api`.\n"
378-
"Run the following `curl` command with the appropriate `--data-urlencode command=...` payload:\n\n"
379-
" `curl -s -d \"chat-source={:adapter :agent :room \\\"agent-room\\\"}\" --data-urlencode \"command=agent <subcommand>\" http://localhost:$YETIBOT_PORT/api`\n\n"
380-
"Where `<subcommand>` is one of:\n"
381-
"- `list-commands`: returns all available built-in commands as a JSON map\n"
382-
"- `list-aliases`: returns all configured command aliases as a JSON map\n"
383-
"- `run <cmd>`: runs the given yetibot command `<cmd>` and returns the output\n\n"
384-
"For example, you can list aliases, find a weather/temp alias, run it to get its data, and then pipe that data to a kroki command to generate a graph!\n\n"
377+
"You have a powerful local tool `./yetibot` in your working directory. You can use it to execute any built-in Yetibot command or alias directly in your shell.\n"
378+
"Run `./yetibot <command>` with any command or alias to get its output. For example:\n"
379+
"- `./yetibot agent list-commands`: returns all available built-in commands as a JSON map\n"
380+
"- `./yetibot agent list-aliases`: returns all configured command aliases as a JSON map\n"
381+
"- `./yetibot temps`: runs the `temps` alias to get weather/temp data\n"
382+
"- `./yetibot kroki <payload>`: generates a chart using kroki\n\n"
383+
"For example, you can run `./yetibot agent list-aliases`, find a weather/temp alias, run it using `./yetibot <alias-name>` to get its data, and then pass that data to another command like `./yetibot \"kroki ...\"` to generate a chart!\n\n"
385384
(when-not (string/blank? mentions) (str mentions "\n\n"))
386385
(when-not (string/blank? context)
387386
(str "This thread's conversation so far, for REFERENCE ONLY — background, "
@@ -422,6 +421,23 @@
422421
(.mkdirs settings-dir)
423422
(spit (io/file settings-dir "settings.json")
424423
(json/write-str {:maxSessionTurns (agent-max-turns)})))
424+
;; write the yetibot helper script
425+
(let [yetibot-script (io/file workdir "yetibot")]
426+
(spit yetibot-script
427+
(str "#!/bin/bash\n"
428+
"if [ $# -eq 0 ]; then\n"
429+
" echo \"Usage: yetibot <command>\"\n"
430+
" exit 1\n"
431+
"fi\n"
432+
"cmd=\"$*\"\n"
433+
"if [[ \"$cmd\" == agent* ]]; then\n"
434+
" payload=\"$cmd\"\n"
435+
"else\n"
436+
" payload=\"agent run $cmd\"\n"
437+
"fi\n"
438+
"curl -s -d \"chat-source={:adapter :agent :room \\\"agent-room\\\"}\" "
439+
"--data-urlencode \"command=$payload\" \"http://localhost:${YETIBOT_PORT:-3003}/api\"\n"))
440+
(.setExecutable yetibot-script true))
425441
(let [pb (doto (ProcessBuilder. [(cli-bin) "--yolo" "--output-format" "json"
426442
"--model" (model)
427443
"--prompt" (build-agent-prompt request context mentions)])

test/yetibot/core/test/commands/agent.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
(fact "includes the mention glossary when present"
5151
(agent/build-agent-prompt "do x" nil "• <@1> is Bob") => (contains "<@1> is Bob"))
5252
(fact "gives the bot an identity"
53-
(agent/build-agent-prompt "do x" nil nil) => (contains "Yetibot")))
53+
(agent/build-agent-prompt "do x" nil nil) => (contains "Yetibot"))
54+
(fact "tells gemini to use `./yetibot` to run yetibot commands"
55+
(agent/build-agent-prompt "do x" nil nil) => (contains "./yetibot")))
5456

5557
(facts "about parse-json-response"
5658
(fact "pulls the response field"

0 commit comments

Comments
 (0)