Usability pass: tool registry, TUI polish, saved keys and settings
Tools - Table-driven tool registry with permission classes and default/minimal profiles; new tools: edit_file, list_dir, glob, grep, delete_file, move_file, todo_write, web_fetch, ask_user (plus read_file paging). - Built-in Myers diff; write tools return unified diffs. - Persistent permission rules (.agent/permissions.json), per-turn undo snapshots (.agent/undo), AGENTS.md project notes, auto-compact at 80% of the model context, cancellable run_shell with process-group kill. TUI - Table-driven slash commands: /provider /key /effort /status /tools /permissions /yolo /undo /retry /diff /export /copy /rename /delete /init /max-steps /todo, with / and @ completion. - Permission modal with diff and prefix rules, ask_user modal, todo panel, header with model/effort/context, bracketed paste, line editing, wide-char cursor, NO_COLOR and ASCII fallback; Esc never quits. Startup and configuration - API keys are entered in the TUI (hidden) and saved per provider in <config>/credentials (0600); env variables are only a fallback. - Last provider, per-provider model and reasoning effort are remembered in <config>/settings.json; --effort/-e and /effort send reasoning_effort (low|medium|high|max) to models that accept it. - DeepSeek preset uses deepseek-flash / deepseek-v4-pro. - Session flags --new/--continue/--resume/--list-sessions, --yolo, --confirm. Compatibility and tests - ncurses detection, macOS/Homebrew support, make install, XDG config dir, POSIX cleanups; Gitea CI (gcc/clang/asan/musl/macOS). - Unit tests for diff, fs tools, registry, undo/perms and config; e2e fixtures multi_file_refactor and ask_or_todo; vendored cJSON.
This commit is contained in:
+11
-110
@@ -1,114 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# E2E: copy mini_calc → temp workspace → optional cst-agent headless → make test.
|
||||
# Usage:
|
||||
# ./scripts/e2e_mini_calc.sh # run agent if credentials exist
|
||||
# ./scripts/e2e_mini_calc.sh --baseline-only # only prove fixture starts RED then skip agent
|
||||
# SKIP_AGENT=1 ./scripts/e2e_mini_calc.sh
|
||||
# E2E on fixtures/mini_calc (kept for compatibility; see e2e_fixture.sh).
|
||||
# ./scripts/e2e_mini_calc.sh [--protocol P] [--provider NAME] [--model M]
|
||||
# ./scripts/e2e_mini_calc.sh --baseline-only # only prove the fixture is RED
|
||||
# SKIP_AGENT=1 ./scripts/e2e_mini_calc.sh # same as --baseline-only
|
||||
# API key: CST_API_KEY / DEEPSEEK_API_KEY / OPENAI_API_KEY / MINIMAX_API_KEY
|
||||
# or ~/.config/cst-agent/credentials.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
FIX="$ROOT/fixtures/mini_calc"
|
||||
OUT="$FIX/out"
|
||||
BASELINE_ONLY=0
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
--baseline-only) BASELINE_ONLY=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$OUT"
|
||||
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
WORKDIR="$(mktemp -d /tmp/cst-mini-calc.XXXXXX)"
|
||||
RESULT="$OUT/result-$STAMP.txt"
|
||||
SESSION_COPY="$OUT/session-$STAMP.jsonl"
|
||||
|
||||
cleanup() { rm -rf "$WORKDIR"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "== mini_calc e2e ==" | tee "$RESULT"
|
||||
echo "workdir=$WORKDIR" | tee -a "$RESULT"
|
||||
echo "stamp=$STAMP" | tee -a "$RESULT"
|
||||
|
||||
# Fresh copy (no .agent from previous runs)
|
||||
cp -a "$FIX/." "$WORKDIR/"
|
||||
rm -rf "$WORKDIR/out" "$WORKDIR/.agent"
|
||||
chmod +x "$WORKDIR/tests/smoke.sh"
|
||||
|
||||
cd "$WORKDIR"
|
||||
make clean >/dev/null 2>&1 || true
|
||||
make
|
||||
|
||||
echo "-- baseline make test (expect FAIL before agent) --" | tee -a "$RESULT"
|
||||
set +e
|
||||
make test >"$OUT/baseline-$STAMP.log" 2>&1
|
||||
base_rc=$?
|
||||
set -e
|
||||
echo "baseline_rc=$base_rc" | tee -a "$RESULT"
|
||||
if [[ "$base_rc" -eq 0 ]]; then
|
||||
echo "UNEXPECTED: fixture already passes; bugs may have been fixed in source." | tee -a "$RESULT"
|
||||
echo "outcome=unexpected_green_fixture" | tee -a "$RESULT"
|
||||
exit 2
|
||||
extra=()
|
||||
if [[ "${SKIP_AGENT:-0}" == "1" ]]; then
|
||||
extra+=(--baseline-only)
|
||||
fi
|
||||
echo "baseline: RED (as expected)" | tee -a "$RESULT"
|
||||
|
||||
if [[ "$BASELINE_ONLY" -eq 1 || "${SKIP_AGENT:-0}" == "1" ]]; then
|
||||
echo "outcome=baseline_ok_agent_skipped" | tee -a "$RESULT"
|
||||
echo "SKIP agent step (--baseline-only or SKIP_AGENT=1)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Need API key for agent step
|
||||
has_key=0
|
||||
if [[ -n "${CST_API_KEY:-}" || -n "${MINIMAX_API_KEY:-}" ]]; then
|
||||
has_key=1
|
||||
elif [[ -f "$HOME/.config/cst-agent/credentials" ]]; then
|
||||
has_key=1
|
||||
fi
|
||||
if [[ "$has_key" -eq 0 ]]; then
|
||||
echo "outcome=baseline_ok_no_api_key" | tee -a "$RESULT"
|
||||
echo "No API key; agent step skipped. Set CST_API_KEY or save credentials."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd "$ROOT"
|
||||
make -s
|
||||
|
||||
mkdir -p "$WORKDIR/.agent"
|
||||
PROMPT="$(cat "$FIX/TASK.md")"
|
||||
export CST_AUTO_APPROVE=1
|
||||
echo "-- cst-agent headless --" | tee -a "$RESULT"
|
||||
set +e
|
||||
"$ROOT/cst-agent" --headless --workspace "$WORKDIR" --session "$WORKDIR/.agent/e2e.jsonl" \
|
||||
--prompt "$PROMPT" >"$OUT/agent-$STAMP.log" 2>&1
|
||||
agent_rc=$?
|
||||
set -e
|
||||
echo "agent_rc=$agent_rc" | tee -a "$RESULT"
|
||||
if [[ -f "$WORKDIR/.agent/e2e.jsonl" ]]; then
|
||||
cp -f "$WORKDIR/.agent/e2e.jsonl" "$SESSION_COPY"
|
||||
echo "session_copy=$SESSION_COPY" | tee -a "$RESULT"
|
||||
fi
|
||||
|
||||
cd "$WORKDIR"
|
||||
set +e
|
||||
make test >"$OUT/after-$STAMP.log" 2>&1
|
||||
test_rc=$?
|
||||
set -e
|
||||
echo "after_test_rc=$test_rc" | tee -a "$RESULT"
|
||||
|
||||
# Classify
|
||||
changed=0
|
||||
if ! diff -q "$FIX/calc.c" "$WORKDIR/calc.c" >/dev/null 2>&1; then
|
||||
changed=1
|
||||
fi
|
||||
echo "calc_c_changed=$changed" | tee -a "$RESULT"
|
||||
|
||||
if [[ "$test_rc" -eq 0 ]]; then
|
||||
echo "outcome=pass" | tee -a "$RESULT"
|
||||
exit 0
|
||||
fi
|
||||
if [[ "$changed" -eq 1 ]]; then
|
||||
echo "outcome=partial" | tee -a "$RESULT"
|
||||
exit 1
|
||||
fi
|
||||
echo "outcome=fail" | tee -a "$RESULT"
|
||||
exit 1
|
||||
exec "$ROOT/scripts/e2e_fixture.sh" mini_calc --out "$ROOT/fixtures/mini_calc/out" \
|
||||
"${extra[@]}" "$@"
|
||||
|
||||
Reference in New Issue
Block a user