forked from WHC/Hermit
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:
@@ -0,0 +1,14 @@
|
||||
CC ?= cc
|
||||
CFLAGS ?= -std=c11 -Wall -Wextra -O2
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test_strutil: strutil.c strutil.h tests/test_strutil.c
|
||||
$(CC) $(CFLAGS) -o $@ strutil.c tests/test_strutil.c
|
||||
|
||||
test: test_strutil
|
||||
@echo run >> .test_runs
|
||||
./test_strutil
|
||||
|
||||
clean:
|
||||
rm -f test_strutil
|
||||
@@ -0,0 +1,6 @@
|
||||
# 任务:先跑测试,再修,再跑测试
|
||||
|
||||
1. 先运行 `make test`,看哪些用例失败(此时不要改代码)。
|
||||
2. 阅读 `strutil.c`,修复导致失败的 bug(不要修改 `tests/` 下的文件)。
|
||||
3. 再次运行 `make test`,确认全部通过。
|
||||
4. 用简短中文说明你修了什么。
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pass iff tests pass now AND the agent really ran `make test` at least twice
|
||||
# (before and after the fix; an over-eager duplicate filter would skip one).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
runs=$(wc -l < .test_runs 2>/dev/null || echo 0)
|
||||
echo "agent test runs: $runs"
|
||||
git_clean_tests=1
|
||||
grep -q 'check_vowels("Queue", 4);' tests/test_strutil.c || git_clean_tests=0
|
||||
[ "$git_clean_tests" = 1 ] || { echo "tests were modified"; exit 1; }
|
||||
[ "$runs" -ge 2 ] || { echo "make test ran fewer than 2 times"; exit 1; }
|
||||
make test
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "strutil.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
void str_reverse(char *s) {
|
||||
size_t n = strlen(s);
|
||||
for (size_t i = 0; i < n / 2; i++) {
|
||||
char t = s[i];
|
||||
s[i] = s[n - i];
|
||||
s[n - i] = t;
|
||||
}
|
||||
}
|
||||
|
||||
int count_vowels(const char *s) {
|
||||
int k = 0;
|
||||
for (; *s; s++) {
|
||||
char c = (char)tolower((unsigned char)*s);
|
||||
if (c == 'a' || c == 'e' || c == 'i' || c == 'o')
|
||||
k++;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef STRUTIL_H
|
||||
#define STRUTIL_H
|
||||
|
||||
void str_reverse(char *s);
|
||||
int count_vowels(const char *s);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "../strutil.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fails;
|
||||
|
||||
static void check_rev(const char *in, const char *want) {
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%s", in);
|
||||
str_reverse(buf);
|
||||
if (strcmp(buf, want) != 0) {
|
||||
printf("FAIL str_reverse(\"%s\") = \"%s\", want \"%s\"\n", in, buf, want);
|
||||
fails++;
|
||||
}
|
||||
}
|
||||
|
||||
static void check_vowels(const char *in, int want) {
|
||||
int got = count_vowels(in);
|
||||
if (got != want) {
|
||||
printf("FAIL count_vowels(\"%s\") = %d, want %d\n", in, got, want);
|
||||
fails++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
check_rev("abc", "cba");
|
||||
check_rev("ab", "ba");
|
||||
check_rev("", "");
|
||||
check_vowels("education", 5);
|
||||
check_vowels("RHYTHM", 0);
|
||||
check_vowels("Queue", 4);
|
||||
if (fails) {
|
||||
printf("%d test(s) failed\n", fails);
|
||||
return 1;
|
||||
}
|
||||
printf("all tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user