Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions bin/omarchy-agent-integrate-herdr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# omarchy:summary=Install herdr's status and session-restore integration for agents mise just installed
# omarchy:hidden=true

# mise runs this as a postinstall hook (etc/mise/conf.d/omarchy.toml), naming the
# tools it just installed in MISE_INSTALLED_TOOLS. Omarchy's agents are lazy and
# self-updating, so that is an agent's first use and every upgrade after it.
# herdr only installs into a config directory the agent already made, and the
# agent makes it on its first run, after this hook, so it is created here.
# A failure only warns: the agent should still start.

config=${XDG_CONFIG_HOME:-$HOME/.config}

while IFS= read -r tool; do
case $tool in
pi) target=pi dir=$HOME/.pi/agent ;;
oh-my-pi) target=omp dir=$HOME/.omp/agent ;;
claude) target=claude dir=${CLAUDE_CONFIG_DIR:-$HOME/.claude} ;;
codex) target=codex dir=${CODEX_HOME:-$HOME/.codex} ;;
grok) target=grok dir=${GROK_HOME:-$HOME/.grok} ;;
copilot) target=copilot dir=$HOME/.copilot ;;
qwen) target=qwen dir=$HOME/.qwen ;;
opencode) target=opencode dir=$config/opencode ;;
antigravity-cli) target=antigravity-cli dir=$HOME/.gemini/config ;;
cursor-agent | http:cursor-agent) target=cursor dir=$HOME/.cursor ;;
http:devin) target=devin dir=$config/devin ;;
npm:@kilocode/cli) target=kilo dir=$config/kilo ;;
npm:@moonshot-ai/kimi-code) target=kimi dir=$HOME/.kimi-code ;;
*) continue ;;
esac

# herdr reports to stdout, which would land on the agent's first screen.
if ! mkdir -p "$dir" || ! herdr integration install "$target" >/dev/null; then
echo "Could not install the herdr integration for $target" >&2
fi
done < <(jq -r '.[].name' <<<"${MISE_INSTALLED_TOOLS:-[]}" 2>/dev/null)

exit 0
4 changes: 4 additions & 0 deletions etc/mise/conf.d/omarchy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ upgrade.auto_prune = false
# Expose only its launcher so the bundled Node cannot shadow the user's Node.
[tool_alias]
cursor-agent = 'http:cursor-agent[bin_path=bin,postinstall=mkdir -p "$MISE_TOOL_INSTALL_PATH/bin" && ln -sfn ../dist-package/cursor-agent "$MISE_TOOL_INSTALL_PATH/bin/cursor-agent"]'

# Coding agents get herdr's status and session-restore hooks when mise installs or upgrades them.
[hooks]
postinstall = "omarchy-agent-integrate-herdr"
33 changes: 33 additions & 0 deletions test/shell.d/agent-integrate-herdr-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -euo pipefail

source "$(dirname "$0")/base-test.sh"

if ! command -v herdr >/dev/null; then
skip "herdr not installed; skipping agent herdr integration"
exit 0
fi

test_home=$(mktemp -d)
trap 'rm -rf -- "$test_home"' EXIT
export HOME=$test_home
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
# herdr honors each of these over HOME, which would reach the developer's own agent homes.
unset PI_CODING_AGENT_DIR PI_CONFIG_DIR COPILOT_HOME KIMI_CODE_HOME OPENCODE_CONFIG_DIR QWEN_HOME \
CURSOR_CONFIG_DIR ANTIGRAVITY_CLI_CONFIG_DIR GROK_CONFIG_DIR QODER_CONFIG_DIR HERMES_HOME XDG_CONFIG_HOME

integration_state() {
herdr integration status | awk -v target="$1" -F ': ' '$1 == target { split($2, state, " "); print state[1] }'
}

# A first install from mise names tools by their mise names, before the agent
# has ever run and made the config directory herdr installs into.
MISE_INSTALLED_TOOLS='[{"name":"grok"},{"name":"npm:@moonshot-ai/kimi-code"},{"name":"oh-my-pi"},{"name":"hunk"}]' \
"$ROOT/bin/omarchy-agent-integrate-herdr" >"$test_home/out.log" 2>&1 || fail "integrating new agents succeeds" "$(cat "$test_home/out.log")"

for target in grok kimi omp; do
[[ $(integration_state "$target") == "current" ]] || fail "a first mise install integrates $target with herdr" "$(herdr integration status)"
done
[[ ! -s $test_home/out.log ]] || fail "integrating stays quiet in the agent's first screen" "$(cat "$test_home/out.log")"
pass "a first mise install integrates the agent with herdr"

Loading