fix: herdr integrations make the hook directory herdr names
herdr writes its hook file but not the directory, so on a fresh box `herdr integration install omp` failed: omp had never created ~/.omp/agent/extensions. The step now reads the target path from `herdr integration status` and makes its directory, only for an agent that is present. The fake herdr fails like the real one when it is missing.
This commit is contained in:
1 parent
c710e1934d
commit
06b03c9528
3 files changed
+54
-11
No files matched your search
+18
-4
@@ -145,16 +145,30 @@ go)
|
|||||||
herdr)
|
herdr)
|
||||||
# `herdr integration status` lists one `<agent>: <state> (...)` line per
|
# `herdr integration status` lists one `<agent>: <state> (...)` line per
|
||||||
# integration; FAKE_HERDR_CURRENT names the agents to report `current`,
|
# integration; FAKE_HERDR_CURRENT names the agents to report `current`,
|
||||||
# every other one is `not installed`. `install` is only logged.
|
# every other one is `not installed`. The paths are the real ones' shape.
|
||||||
|
# `install` writes nothing, but like the real herdr it fails when the
|
||||||
|
# target's directory is missing: herdr does not create ~/.omp/agent/extensions.
|
||||||
|
_herdr_target() {
|
||||||
|
case $1 in
|
||||||
|
pi) echo "$HOME/.pi/agent/extensions/herdr-agent-state.ts" ;;
|
||||||
|
omp) echo "$HOME/.omp/agent/extensions/herdr-omp-agent-state.ts" ;;
|
||||||
|
claude) echo "$HOME/.claude/hooks/herdr-agent-state.sh" ;;
|
||||||
|
codex) echo "$HOME/.codex/herdr-agent-state.sh" ;;
|
||||||
|
*) echo "$HOME/.$1/hooks/herdr-agent-state.sh" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
case ${1:-}:${2:-} in
|
case ${1:-}:${2:-} in
|
||||||
integration:status)
|
integration:status)
|
||||||
for _a in pi omp claude codex copilot; do
|
for _a in pi omp claude codex copilot; do
|
||||||
case " ${FAKE_HERDR_CURRENT:-} " in
|
case " ${FAKE_HERDR_CURRENT:-} " in
|
||||||
*" $_a "*) printf '%s: current (v11) (%s/.fake/%s)\n' "$_a" "$HOME" "$_a" ;;
|
*" $_a "*) printf '%s: current (v11) (%s)\n' "$_a" "$(_herdr_target "$_a")" ;;
|
||||||
*) printf '%s: not installed (%s/.fake/%s)\n' "$_a" "$HOME" "$_a" ;;
|
*) printf '%s: not installed (%s)\n' "$_a" "$(_herdr_target "$_a")" ;;
|
||||||
esac
|
esac
|
||||||
done ;;
|
done ;;
|
||||||
integration:install) [ "$mode" = install ] && exit 1 ;;
|
integration:install)
|
||||||
|
[ "$mode" = install ] && exit 1
|
||||||
|
_t=$(_herdr_target "${3:-}")
|
||||||
|
[ -d "${_t%/*}" ] || { echo "error: ${_t%/*}: No such file or directory" >&2; exit 1; } ;;
|
||||||
esac
|
esac
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
nvim)
|
nvim)
|
||||||
|
|||||||
@@ -807,6 +807,17 @@ hasnt "…and prints no herdr section" "herdr integrations" "$out"
|
|||||||
BOXENV='FAKE_FAIL=herdr:install'
|
BOXENV='FAKE_FAIL=herdr:install'
|
||||||
out=$(box install 2>&1 | plain || true)
|
out=$(box install 2>&1 | plain || true)
|
||||||
has "a failed integration is named" "herdr integration install claude failed" "$out"
|
has "a failed integration is named" "herdr integration install claude failed" "$out"
|
||||||
|
# herdr writes the hook file but not its directory, and on a fresh box omp has
|
||||||
|
# never made ~/.omp/agent/extensions. The installer makes the directory herdr's
|
||||||
|
# own status names, and only for an agent that is present.
|
||||||
|
newbox; sh ./seal.sh "$SB/seal" --with herdr omp >/dev/null; BOXPATH=$SB/seal
|
||||||
|
pick core/ripgrep
|
||||||
|
out=$(box install 2>&1 | plain || true)
|
||||||
|
hasnt "omp installs with no extensions dir yet" "herdr integration install omp failed" "$out"
|
||||||
|
is "…the dir herdr names is made for it" "yes" \
|
||||||
|
"$([ -d "$SB/.omp/agent/extensions" ] && echo yes || echo no)"
|
||||||
|
is "…and none for an agent that is not here" "no" \
|
||||||
|
"$([ -d "$SB/.pi/agent/extensions" ] && echo yes || echo no)"
|
||||||
newbox; sh ./seal.sh "$SB/seal" --with claude codex >/dev/null; BOXPATH=$SB/seal
|
newbox; sh ./seal.sh "$SB/seal" --with claude codex >/dev/null; BOXPATH=$SB/seal
|
||||||
if grep -q '^herdr ' "$SB/seal/.shadowed" 2>/dev/null; then
|
if grep -q '^herdr ' "$SB/seal/.shadowed" 2>/dev/null; then
|
||||||
printf ' \033[33mskip\033[0m herdr sits at an absolute path find_tool probes\n'
|
printf ' \033[33mskip\033[0m herdr sits at an absolute path find_tool probes\n'
|
||||||
@@ -1511,6 +1522,8 @@ STEPS
|
|||||||
"chezmoi init --apply --source $SB/.local/share/dotfiles-private" "$(cat "$LOG")"
|
"chezmoi init --apply --source $SB/.local/share/dotfiles-private" "$(cat "$LOG")"
|
||||||
has "…against the private tier's OWN config file" \
|
has "…against the private tier's OWN config file" \
|
||||||
"-c $SB/.config/chezmoi/private.toml" "$(cat "$LOG")"
|
"-c $SB/.config/chezmoi/private.toml" "$(cat "$LOG")"
|
||||||
|
has "…and its OWN persistent state, not the public tier's" \
|
||||||
|
"--persistent-state $SB/.config/chezmoi/chezmoistate-private.boltdb" "$(cat "$LOG")"
|
||||||
is "…which is never the config the public tier rewrites" "0" \
|
is "…which is never the config the public tier rewrites" "0" \
|
||||||
"$(grep -c 'chezmoi/chezmoi.toml' "$LOG" || true)"
|
"$(grep -c 'chezmoi/chezmoi.toml' "$LOG" || true)"
|
||||||
is "a later update can still authenticate" "1" \
|
is "a later update can still authenticate" "1" \
|
||||||
|
|||||||
@@ -1219,11 +1219,18 @@ herdr_integrations() {
|
|||||||
hd=
|
hd=
|
||||||
for ag in claude codex pi omp; do
|
for ag in claude codex pi omp; do
|
||||||
have "$ag" || continue
|
have "$ag" || continue
|
||||||
case $(printf '%s\n' "$hst" | grep "^$ag: " || :) in
|
hl=$(printf '%s\n' "$hst" | grep "^$ag: " || :)
|
||||||
|
case $hl in
|
||||||
*": current"*) continue ;;
|
*": current"*) continue ;;
|
||||||
esac
|
esac
|
||||||
[ -n "$hd" ] || { head_ "herdr integrations"; hd=1; }
|
[ -n "$hd" ] || { head_ "herdr integrations"; hd=1; }
|
||||||
run_sh "'$HERDR' integration install $ag" \
|
# herdr writes the hook file but not its directory, and an agent that
|
||||||
|
# has never run (omp on a fresh box) has no ~/.omp/agent/extensions
|
||||||
|
# yet. The status line ends with the target path; make its directory.
|
||||||
|
hdir=$(printf '%s\n' "$hl" | sed -n 's/^.*(\(\/.*\)\/[^/]*)$/\1/p')
|
||||||
|
hmk=
|
||||||
|
[ -n "$hdir" ] && [ ! -d "$hdir" ] && hmk="mkdir -p '$hdir' && "
|
||||||
|
run_sh "$hmk'$HERDR' integration install $ag" \
|
||||||
|| warn "herdr integration install $ag failed — agent state will not show in herdr"
|
|| warn "herdr integration install $ag failed — agent state will not show in herdr"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1366,6 +1373,14 @@ BWS_TOKEN=${DOTUP_BWS_TOKEN:-${XDG_CONFIG_HOME:-$HOME/.config}/bitwarden/bws-tok
|
|||||||
# are, days later, with nothing connecting it to the install you ran.
|
# are, days later, with nothing connecting it to the install you ran.
|
||||||
PRIV_CFG=${DOTUP_PRIVATE_CFG:-${XDG_CONFIG_HOME:-$HOME/.config}/chezmoi/private.toml}
|
PRIV_CFG=${DOTUP_PRIVATE_CFG:-${XDG_CONFIG_HOME:-$HOME/.config}/chezmoi/private.toml}
|
||||||
|
|
||||||
|
# ...and its own persistent state, for the same reason. chezmoi keeps the state
|
||||||
|
# next to the config file, so both tiers shared chezmoistate.boltdb and each
|
||||||
|
# overwrote the other's config-template hash: after the private init, every
|
||||||
|
# public command warned "config file template has changed". The private
|
||||||
|
# template names this file as persistentState too, but init opens the state
|
||||||
|
# before it writes that config, so the flag is what makes the first init right.
|
||||||
|
PRIV_STATE=$(dirname "$PRIV_CFG")/chezmoistate-private.boltdb
|
||||||
|
|
||||||
# git's credential store for the private remote.
|
# git's credential store for the private remote.
|
||||||
#
|
#
|
||||||
# The clone URL the endpoint hands back carries the token inline, and handing
|
# The clone URL the endpoint hands back carries the token inline, and handing
|
||||||
@@ -1553,12 +1568,13 @@ cmd_private() {
|
|||||||
# transcript capturing the run.
|
# transcript capturing the run.
|
||||||
mkdir -p "$(dirname "$PRIV_CFG")"
|
mkdir -p "$(dirname "$PRIV_CFG")"
|
||||||
if [ "$DRYRUN" -eq 1 ]; then
|
if [ "$DRYRUN" -eq 1 ]; then
|
||||||
printf ' + chezmoi init --apply --source %s -c %s %s\n' \
|
printf ' + chezmoi init --apply --source %s -c %s --persistent-state %s %s\n' \
|
||||||
"$PRIV_SRC" "$PRIV_CFG" "$(redact_url "$p_clean")"
|
"$PRIV_SRC" "$PRIV_CFG" "$PRIV_STATE" "$(redact_url "$p_clean")"
|
||||||
else
|
else
|
||||||
printf '%s + chezmoi init --apply --source %s -c %s %s%s\n' \
|
printf '%s + chezmoi init --apply --source %s -c %s --persistent-state %s %s%s\n' \
|
||||||
"$DIM" "$PRIV_SRC" "$PRIV_CFG" "$(redact_url "$p_clean")" "$R" >&2
|
"$DIM" "$PRIV_SRC" "$PRIV_CFG" "$PRIV_STATE" "$(redact_url "$p_clean")" "$R" >&2
|
||||||
"$CHEZMOI" init --apply --source "$PRIV_SRC" -c "$PRIV_CFG" "$p_clean" \
|
"$CHEZMOI" init --apply --source "$PRIV_SRC" -c "$PRIV_CFG" \
|
||||||
|
--persistent-state "$PRIV_STATE" "$p_clean" \
|
||||||
|| err "private repo init failed"
|
|| err "private repo init failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user