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:
WHC
2026-10-05 01:47:01 +08:00
parent 9877ff48b6
commit 2fde898da0
105 changed files with 19348 additions and 3786 deletions
+20
View File
@@ -0,0 +1,20 @@
# Task: three small scripts, planned with a task list
Create these files in the workspace root:
1. `greet.sh` — prints `Hello, NAME!` where NAME is the first argument, or
`Hello, world!` when no argument is given.
2. `count.sh` — prints the number of lines in the file given as the first
argument (just the number). Exits with status 2 and prints a usage line to
stderr when no argument is given.
3. `SCRIPTS.md` — one short section per script explaining how to run it.
Both scripts must be executable POSIX shell scripts (`#!/bin/sh`).
Rules:
- Start by calling `todo_write` with one item per file, then keep the list
up to date (mark each item done as you finish it). Every item must be done
at the end.
- Nobody is available to answer questions in this run. If `ask_user` fails,
pick a sensible default and continue.
- Test both scripts with `run_shell` before you finish.
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Pass iff the scripts work and the agent kept a finished task list.
set -euo pipefail
cd "$(dirname "$0")"
fail() { echo "check: $*"; exit 1; }
[[ -x greet.sh && -x count.sh ]] || fail "scripts missing or not executable"
[[ "$(./greet.sh)" == "Hello, world!" ]] || fail "greet.sh without argument"
[[ "$(./greet.sh Ada)" == "Hello, Ada!" ]] || fail "greet.sh Ada"
[[ "$(./count.sh notes.txt | tr -d ' ')" == "3" ]] || fail "count.sh notes.txt"
set +e
./count.sh >/dev/null 2>&1
rc=$?
set -e
[[ "$rc" -eq 2 ]] || fail "count.sh without argument should exit 2 (got $rc)"
[[ -s SCRIPTS.md ]] || fail "SCRIPTS.md missing"
grep -q greet.sh SCRIPTS.md && grep -q count.sh SCRIPTS.md ||
fail "SCRIPTS.md does not mention both scripts"
# The session must show todo_write ending with every item done.
python3 - <<'PY' || fail "no finished todo_write list in the session"
import glob, json, re, sys
last = None
for path in glob.glob(".agent/*.jsonl") + glob.glob(".agent/sessions/*.jsonl"):
for line in open(path, encoding="utf-8"):
try:
m = json.loads(line)
except ValueError:
continue
c = m.get("content") or ""
r = re.search(r"todo list updated: (\d+)/(\d+) done", c)
if r:
last = (int(r.group(1)), int(r.group(2)))
sys.exit(0 if last and last[1] >= 3 and last[0] == last[1] else 1)
PY
echo "check: PASSED"
+3
View File
@@ -0,0 +1,3 @@
first
second
third