Both scripts wrap something every agent on this repo ends up doing by hand,
and each encodes a constraint that is easy to get wrong once and expensive
to get wrong twice. Agent-agnostic on purpose -- plain scripts, plain text
output -- so opencode agents use the same ones rather than each
hand-rolling the equivalent command and getting a different detail wrong.
Indexed from AGENTS.md; the reasoning is in scripts/README.md.
scripts/sandbox.sh -- throwaway router on 8081. Encodes the port convention
(8080 is production and this cannot bind it), the kill discipline (only a
pid it recorded itself; never kill-by-name, Restart=always will fight you
and on this machine that process is the operator's model access), and the
cwd-vs-PYTHONPATH split that decides which config.yaml, which router.db and
which admin/frontend get used.
Writing it found two bugs in itself, both only visible by running it:
- `sandbox.sh start | tail` hung until the SERVER exited, because the
child inherited the script's stdout and held the pipe open. Fixed with
</dev/null and all three fds redirected.
- $! recorded a pid one off from the real uvicorn, so `stop` reported
success while the server kept running and `status` said "not running"
against a live :8081 answering 200. Fixed by backgrounding the command
directly instead of inside `( ... & echo $! )`, plus a post-start check
that the recorded pid is the one actually holding the port -- without
that check both bugs printed success.
scripts/mkpr.sh -- cut a gitea PR with a long markdown body. `tea pr
create` has no --description-file, so the body must arrive via $(cat ...),
which a worktree-pinned agent session refuses as too complex to verify;
running it from a script file sidesteps that without weakening it. Passes
--remote origin as well as --repo because AGENTS.md notes the `alee` login
is not tea's default. Refuses a head branch that is unpushed, diverged from
its remote, or not ahead of the base -- tea will cheerfully do all three.
Deliberately not scripted: merging to main (needs main checked out, which
conflicts with any agent in a worktree), Seed Energy and Restart Service
(one spends real credit, the other restarts production), and anything that
writes config.local.yaml.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRQXz5SYZYVWscxS1QqF6U
55 lines
2.0 KiB
Bash
Executable File
55 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Cut a gitea PR with a long markdown body.
|
|
#
|
|
# mkpr.sh <body.md> "<title>" [head-branch] [base-branch]
|
|
#
|
|
# Exists because two things get in the way of a one-liner:
|
|
#
|
|
# 1. `tea pr create` has no --description-file, only --description, so the
|
|
# body has to arrive via $(cat ...) -- and a Claude Code session pinned
|
|
# to a worktree refuses that invocation as "too complex to verify it
|
|
# stays inside the worktree". Running it from a script file sidesteps
|
|
# the check without weakening it.
|
|
# 2. The head branch must already be pushed. tea will happily open a PR
|
|
# against a ref the server does not have, so this checks first.
|
|
set -euo pipefail
|
|
|
|
BODY_FILE="${1:?usage: mkpr.sh <body.md> \"<title>\" [head] [base]}"
|
|
TITLE="${2:?missing title}"
|
|
HEAD="${3:-$(git rev-parse --abbrev-ref HEAD)}"
|
|
BASE="${4:-main}"
|
|
REPO_SLUG="${MKPR_REPO:-alee/6krrt}"
|
|
|
|
[ -s "$BODY_FILE" ] || { echo "body file is empty or missing: $BODY_FILE" >&2; exit 1; }
|
|
|
|
git fetch origin --quiet
|
|
|
|
if ! git rev-parse --verify --quiet "origin/$HEAD" >/dev/null; then
|
|
echo "origin/$HEAD does not exist -- push the branch first:" >&2
|
|
echo " git push origin $HEAD" >&2
|
|
exit 1
|
|
fi
|
|
if [ "$(git rev-parse "$HEAD")" != "$(git rev-parse "origin/$HEAD")" ]; then
|
|
echo "local $HEAD and origin/$HEAD differ -- push before opening the PR:" >&2
|
|
echo " git push origin $HEAD" >&2
|
|
exit 1
|
|
fi
|
|
|
|
AHEAD="$(git rev-list --count "origin/$BASE..origin/$HEAD")"
|
|
if [ "$AHEAD" -eq 0 ]; then
|
|
echo "origin/$HEAD is not ahead of origin/$BASE -- nothing to open a PR for" >&2
|
|
exit 1
|
|
fi
|
|
echo "opening PR for $AHEAD commit(s): $BASE <- $HEAD"
|
|
|
|
# --remote origin as well as --repo: AGENTS.md notes the `alee` login is not
|
|
# tea's default, so the login has to be discovered from the remote. The two
|
|
# flags compose -- --repo picks the repo, --remote picks the login.
|
|
tea pr create \
|
|
--repo "$REPO_SLUG" \
|
|
--remote origin \
|
|
--head "$HEAD" \
|
|
--base "$BASE" \
|
|
--title "$TITLE" \
|
|
--description "$(cat "$BODY_FILE")"
|