chore: add project docs and agent workflow setup
This commit is contained in:
1 parent
b647343c99
commit
95e1b9cb89
15 files changed
+894
-1
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Gitea API helper for managing this project (issues, labels, milestones, board, PRs).
|
||||
# Not part of the Deverenz product.
|
||||
#
|
||||
# Usage: gitea.sh METHOD PATH [BODY]
|
||||
# METHOD GET | POST | PATCH | PUT | DELETE
|
||||
# PATH path below /api/v1, e.g. /repos/<owner>/<repo>/issues?state=open
|
||||
# BODY JSON string, or @file to send a file
|
||||
#
|
||||
# Config (outside the repo, never committed):
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/deverenz-agent/url e.g. http://gitea.local:3000
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/deverenz-agent/token agent account token, chmod 600
|
||||
set -euo pipefail
|
||||
|
||||
method=${1:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
path=${2:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
body=${3:-}
|
||||
|
||||
case "$method" in
|
||||
GET | POST | PATCH | PUT | DELETE) ;;
|
||||
*) echo "unsupported method: $method" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
config=${XDG_CONFIG_HOME:-$HOME/.config}/deverenz-agent
|
||||
for f in url token; do
|
||||
[[ -s "$config/$f" ]] || { echo "missing $config/$f (see CLAUDE.local.md)" >&2; exit 2; }
|
||||
done
|
||||
url=$(<"$config/url")
|
||||
token=$(<"$config/token")
|
||||
|
||||
args=(-sS --fail-with-body -X "$method" -H "Accept: application/json")
|
||||
# The token header is read from stdin so it never shows up in the process list.
|
||||
args+=(-H @-)
|
||||
if [[ -n "$body" ]]; then
|
||||
[[ "$body" == "@-" ]] && { echo "BODY from stdin is not supported, use @file" >&2; exit 2; }
|
||||
args+=(-H "Content-Type: application/json" --data-binary "$body")
|
||||
fi
|
||||
|
||||
out=$(curl "${args[@]}" "${url%/}/api/v1${path}" <<<"Authorization: token $token") \
|
||||
|| { echo "$out" >&2; exit 1; }
|
||||
if command -v jq >/dev/null && [[ -n "$out" ]]; then
|
||||
jq . <<<"$out" 2>/dev/null || echo "$out"
|
||||
else
|
||||
echo "$out"
|
||||
fi
|
||||
Reference in new issue
Block a user