FinalToken v1: a NativeAOT tray app for Windows 11 and CachyOS that tracks Claude Code and Codex usage and limits through their CLIs only, with no provider sign-in and no tokens (R1-R7, D1-D11). - Core: incremental collectors for Claude transcripts and Codex rollouts, limit probes through `claude -p /usage` and `codex app-server`, a journaled history store, the refresh engine, pace and popup decisions, and the snapshot.json contract. - App (Avalonia): stats panel with limit bars, pace, projections, token totals, charts, limit history and breakdowns; tray, settings, non-activating pace popups, single-instance activation, start with the OS, and the Off/Ask/Automatic Stream Deck plugin install. - Stream Deck plugin (SDK v2, NativeAOT) for Elgato and OpenDeck. - finaltoken-cli, tools/publish.py, the documentation check and the agent review workflow. Closes #1
34 lines
1.8 KiB
Bash
Executable File
34 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Usage: tools/agent-review.sh <pr> <full 40-char sha> <pass|fail> <review.md>
|
|
set -euo pipefail
|
|
usage() { echo 'Usage: tools/agent-review.sh <pr> <full 40-char sha> <pass|fail> <review.md>' >&2; exit 2; }
|
|
[[ $# == 4 ]] || usage
|
|
pr=$1 sha=$2 verdict=$3 file=$4
|
|
[[ $pr =~ ^[1-9][0-9]*$ && $sha =~ ^[0-9a-f]{40}$ ]] || usage
|
|
case $verdict in
|
|
pass) state=success ;;
|
|
fail) state=failure ;;
|
|
*) usage ;;
|
|
esac
|
|
[[ -s $file && -r $file ]] || { echo "Review file '$file' is missing, empty or unreadable" >&2; exit 2; }
|
|
command -v jq >/dev/null 2>&1 || { echo 'agent-review requires jq' >&2; exit 1; }
|
|
gitea=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/gitea.sh
|
|
repo=/repos/FinalFactory/FinalToken
|
|
|
|
info=$(bash "$gitea" GET "$repo/pulls/$pr") || { echo "PR $pr not found or could not be read" >&2; exit 1; }
|
|
prstate=$(jq -er '.state' <<< "$info") || { echo "PR $pr response has no state" >&2; exit 1; }
|
|
head=$(jq -er '.head.sha' <<< "$info") || { echo "PR $pr response has no head" >&2; exit 1; }
|
|
[[ $prstate == open ]] || { echo "PR $pr is $prstate" >&2; exit 1; }
|
|
[[ $head == "$sha" ]] || { echo "PR $pr head is $head, not the reviewed $sha: review the new head" >&2; exit 1; }
|
|
|
|
url=$(jq -n --arg b "**Agent review: $verdict** on $sha" --rawfile r "$file" '{body: ($b + "\n\n" + $r)}' \
|
|
| bash "$gitea" POST "$repo/issues/$pr/comments" - | jq -er '.html_url // empty') || {
|
|
echo 'Posting the review comment failed' >&2; exit 1;
|
|
}
|
|
id=$(jq -n --arg s "$state" --arg d "agent review: $verdict" --arg u "$url" \
|
|
'{state: $s, context: "agent-review", description: $d, target_url: $u}' \
|
|
| bash "$gitea" POST "$repo/statuses/$sha" - | jq -er '.id // empty') || {
|
|
echo "The comment is posted ($url) but setting the status failed" >&2; exit 1;
|
|
}
|
|
echo "agent-review $verdict on $sha: $url (status $id)"
|