diff --git a/README.md b/README.md index 2cf65f5..079ce76 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ image: https://example.com/cover.png tags: [ai, agent, aiharness] --- -# aish +# aish v0.0.1 ``` , , @@ -61,6 +61,7 @@ With options: ```sh $ ./ai.sh -v what is 2 plus 2 + [loaded /home/user/.aish/log.jsonl — 3 messages, $0.0001 spent] [step 1] (reasoning) The user wants to know 2 plus 2. [done] 2 plus 2 is 4. @@ -68,21 +69,8 @@ $ ./ai.sh -v what is 2 plus 2 [finished — 1 steps, $0.0001 spent] ``` -```sh -$ ./ai.sh -m gpt-4o "write a hello world program in python. save it in ~/" -I've created a Python hello world program at ~/hello.py: -```python -print("Hello, World!") -``` -You can run it with `python3 ~/hello.py`. -``` - -```sh -$ ./ai.sh -R what is the capital of France -The capital of France is Paris. -``` The agent can run shell commands, read files, and execute multi-step tasks. Context is saved and resumed on subsequent calls. @@ -225,14 +213,16 @@ That's it. No build step, no install script, no daemon. | `-a` | `--autonomous` | Autonomous mode (run until done or budget exhausted) | | `-i` | `--init` | Create local `.aish/` with defaults, exit | | `-x` | `--clear` | Clear the log file and exit | +| `-r` | `--reset` | Clear the log file and exit (alias for `-x`) | +| `-t` | `--tail` | Tail (follow) the log file in real time | | `-v` | `--verbose` | Show status lines | | `-m` | `--model` | Override model | | `-k` | `--api-key` | API key (or set `PPQ_API_KEY`) | | `-C` | `--max-cost` | Override max cost (USD) | | `-s` | `--max-steps` | Override max steps | -| `-t` | `--timeout` | Override overall timeout (seconds) | +| | `--timeout` | Override overall timeout (seconds) | | `-T` | `--cmd-timeout` | Override per-command timeout (seconds) | -| `-r` | `--resume` | Resume from existing log (default: yes) | +| | `--resume` | Resume from existing log (default: yes) | | `-R` | `--no-resume` | Start fresh (ignore existing log) | | `-h` | `--help` | Show help | diff --git a/ai.sh b/ai.sh index 38e6df3..92e3032 100755 --- a/ai.sh +++ b/ai.sh @@ -170,15 +170,17 @@ Options: -a, --autonomous Run in autonomous mode (goal required) -i, --init Create local .aish/ with default config + prompt, exit -x, --clear Clear the log file and exit + -r, --reset Clear the log file and exit (alias for -x) + -t, --tail Tail (follow) the log file in real time -v, --verbose Show status lines ([loaded], [step], [finished], etc.) Default is quiet: only the response is printed. -m, --model MODEL Override model from config -k, --api-key KEY API key (or set PPQ_API_KEY env var) -C, --max-cost USD Override max cost from config -s, --max-steps N Override max steps from config - -t, --timeout SECS Override overall timeout from config + --timeout SECS Override overall timeout from config -T, --cmd-timeout SECS Override per-command timeout from config - -r, --resume Resume from existing log (default: yes) + --resume Resume from existing log (default: yes) -R, --no-resume Start fresh (ignore existing log) -h, --help Show this help @@ -202,6 +204,7 @@ IS_AUTONOMOUS=0 CMD_MODE=0 INIT_MODE=0 CLEAR_MODE=0 +TAIL_MODE=0 VERBOSE=0 MODEL_OVERRIDE="" API_KEY_OVERRIDE="" @@ -1058,10 +1061,14 @@ while [ $i -le $# ]; do INIT_MODE=1 i=$((i+1)) ;; - --clear|-x) + --clear|-x|--reset|-r) CLEAR_MODE=1 i=$((i+1)) ;; + --tail|-t) + TAIL_MODE=1 + i=$((i+1)) + ;; --model|-m) i=$((i+1)); eval "MODEL_OVERRIDE=\"\${$i}\""; i=$((i+1)) ;; @@ -1076,7 +1083,7 @@ while [ $i -le $# ]; do i=$((i+1)); eval "MAX_STEPS_OVERRIDE=\"\${$i}\"" HAS_MAX_STEPS=1; i=$((i+1)) ;; - --timeout|-t) + --timeout) i=$((i+1)); eval "TIMEOUT_OVERRIDE=\"\${$i}\"" HAS_TIMEOUT=1; i=$((i+1)) ;; @@ -1084,7 +1091,7 @@ while [ $i -le $# ]; do i=$((i+1)); eval "CMD_TIMEOUT_OVERRIDE=\"\${$i}\"" HAS_CMD_TIMEOUT=1; i=$((i+1)) ;; - --resume|-r) + --resume) RESUME=1; i=$((i+1)) ;; --no-resume|-R) @@ -1107,7 +1114,7 @@ while [ $i -le $# ]; do esac done -# --clear: delete the log file and exit. +# --clear / --reset: delete the log file and exit. if [ "$CLEAR_MODE" = "1" ]; then if [ -f "$LOG_PATH" ]; then rm -f "$LOG_PATH" @@ -1118,6 +1125,17 @@ if [ "$CLEAR_MODE" = "1" ]; then exit 0 fi +# --tail: follow the log file in real time. +if [ "$TAIL_MODE" = "1" ]; then + if [ -f "$LOG_PATH" ]; then + tail -f "$LOG_PATH" + else + echo "No log to tail ($LOG_PATH does not exist)" >&2 + exit 1 + fi + exit 0 +fi + # --init: create local .aish/ with default config + prompt, then exit. if [ "$INIT_MODE" = "1" ]; then mkdir -p "$LOCAL_DIR" || { echo "error: failed to create $LOCAL_DIR" >&2; exit 1; }