feat(t3code): move agent identity overlay here, support two Gitea instances
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f683e8bf43
commit
071161b6d6
2 files changed
+209
No files matched your search
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
# Checks for overlays.t3code-agent-identity with a stub t3 that runs its
|
||||
# arguments inside the wrapper's environment.
|
||||
# Usage: t3code-agent-identity.test.sh
|
||||
set -euo pipefail
|
||||
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
repo="$(cd "$here/.." && pwd)"
|
||||
fail=0
|
||||
|
||||
contains() { # name, haystack, needle
|
||||
if [[ "$2" == *"$3"* ]]; then echo "ok $1"; else echo "FAIL $1: missing '$3' in '$2'"; fail=1; fi
|
||||
}
|
||||
refute() { # name, haystack, needle
|
||||
if [[ "$2" == *"$3"* ]]; then echo "FAIL $1: found '$3'"; fail=1; else echo "ok $1"; fi
|
||||
}
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
secret="fake-token-$$-do-not-leak"
|
||||
|
||||
build() { # m3ta token file, az token file
|
||||
nix build --no-link --print-out-paths --impure --expr "
|
||||
let
|
||||
flake = builtins.getFlake \"path:$repo\";
|
||||
pkgs = import flake.inputs.nixpkgs {
|
||||
system = \"x86_64-linux\";
|
||||
overlays = [
|
||||
(final: prev: {
|
||||
llm-agents.t3code = final.writeShellScriptBin \"t3\" ''exec \"\$@\"'';
|
||||
llm-agents.t3code-desktop = final.writeShellScriptBin \"t3-desktop\" ''exec \"\$@\"'';
|
||||
})
|
||||
(import $repo/overlays/t3code-agent-identity.nix {
|
||||
tokenFiles = {m3ta = \"$1\"; az = \"$2\";};
|
||||
})
|
||||
];
|
||||
};
|
||||
in pkgs.llm-agents.t3code"
|
||||
}
|
||||
|
||||
printf '%s' "$secret" >"$work/token"
|
||||
both="$(build "$work/token" "$work/token")"
|
||||
az_only="$(build "$work/missing" "$work/token")"
|
||||
none="$(build "$work/missing" "$work/missing")"
|
||||
|
||||
export TMPDIR="$work/tmp"
|
||||
mkdir "$TMPDIR"
|
||||
|
||||
t3() { "$1/bin/t3" "${@:2}"; }
|
||||
|
||||
out="$(t3 "$both" tea logins)"
|
||||
contains "both: m3ta login" "$out" "https://code.m3ta.dev"
|
||||
contains "both: az login" "$out" "https://git.az-gruppe.com"
|
||||
refute "login list hides the token" "$out" "$secret"
|
||||
|
||||
out="$(t3 "$az_only" tea logins)"
|
||||
contains "az only: az login" "$out" "https://git.az-gruppe.com"
|
||||
refute "az only: no m3ta login" "$out" "code.m3ta.dev"
|
||||
out="$(t3 "$az_only" tea logins default)"
|
||||
contains "az only: az is default" "$out" "az"
|
||||
|
||||
t3 "$none" tea logins >/dev/null && echo "ok no token: tea still runs" || { echo "FAIL no token: tea failed"; fail=1; }
|
||||
|
||||
if [ -n "$(ls -A "$TMPDIR")" ]; then echo "FAIL temp config left behind"; fail=1; else echo "ok temp config removed"; fi
|
||||
if grep -rqF "$secret" "$both/bin"/; then echo "FAIL token in the store"; fail=1; else echo "ok token not in the wrapper"; fi
|
||||
|
||||
sshcmd="$(t3 "$both" printenv GIT_SSH_COMMAND)"
|
||||
g() { $sshcmd -G "$1"; }
|
||||
|
||||
out="$(g git.az-gruppe.com)"
|
||||
contains "az: port" "$out" "port 2022"
|
||||
contains "az: user" "$out" "user gitea"
|
||||
contains "az: key" "$out" "identityfile ~/.ssh/m3ta-chiron"
|
||||
known="$(echo "$out" | awk '/^userknownhostsfile/ {print $2}')"
|
||||
contains "az: host key" "$(cat "$known")" "[git.az-gruppe.com]:2022 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIItSijmU5YwcJcoshtmYxpxBaVA4TPaCMk23ws7KDkAH"
|
||||
|
||||
out="$(g code.m3ta.dev)"
|
||||
contains "m3ta: port" "$out" "port 22"
|
||||
contains "m3ta: user" "$out" "user gitea"
|
||||
contains "m3ta: key" "$out" "identityfile ~/.ssh/m3ta-chiron"
|
||||
contains "m3ta: host key" "$(cat "$known")" "code.m3ta.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmmqZ4GgDEXJgj8uYrZAr/EoLIA6LJGkTIyKGQD/60a"
|
||||
|
||||
refute "other hosts keep their own key" "$(g example.org)" "m3ta-chiron"
|
||||
|
||||
contains "author" "$(t3 "$both" printenv GIT_AUTHOR_NAME)" "m3ta-chiron"
|
||||
contains "committer" "$(t3 "$both" printenv GIT_COMMITTER_EMAIL)" "m3ta-chiron@agentmail.to"
|
||||
contains "beads actor" "$(t3 "$both" printenv BEADS_ACTOR)" "m3ta-chiron"
|
||||
|
||||
exit "$fail"
|
||||
Reference in new issue
Block a user