Merge pull request 'Guide models to read-only inspection' (#133) from feat/inspect-guidelines into main

This commit was merged in pull request #133.
This commit is contained in:
hermes committed 2026-10-06 13:14:44 +00:00
commit c29df05e0b
7 files changed
+70 -11

No files matched your search

+2 -2
View File
@@ -1,13 +1,13 @@
"""Scripted fake of the Anthropic SSE API for end-to-end tests of `hx -p`.
Turn 1: tool_use write hello.txt. Turn 2: tool_use bash sort. Turn 3: final text.
Turn 1: tool_use write hello.txt. Turn 2: tool_use bash sed. Turn 3: final text.
Usage: python3 tests/fake_anthropic.py PORT [TURNS.json]
"""
import http.server, json, sys
TURNS = [
[("tool_use", {"id": "t1", "name": "Write", "input": {"path": "hello.txt", "content": "hi from hx\n"}})],
[("tool_use", {"id": "t2", "name": "Bash", "input": {"command": "sort hello.txt"}})],
[("tool_use", {"id": "t2", "name": "Bash", "input": {"command": "sed -n p hello.txt"}})],
[("text", "Done: file says hi from hx.")],
]
if len(sys.argv) > 2: # optional scripted turns: JSON [[["tool_use", {...}] | ["text", "..."], ...], ...]
+2 -2
View File
@@ -52,13 +52,13 @@ kill $srv; rm -f hello.txt
# 3) extension blocks the bash call (cat) and registers its tool
start 3
printf '[[extensions]]\ncommand = ["python3", "%s/examples/ext_guard.py", "sort hello"]\n' "$root" >> "$tmp/home/.hx/config.toml"
printf '[[extensions]]\ncommand = ["python3", "%s/examples/ext_guard.py", "sed -n p hello"]\n' "$root" >> "$tmp/home/.hx/config.toml"
"$root/target/debug/hx" -p "go" --mode json > "$tmp/ext" 2> "$tmp/err" || fail "ext run" "$tmp/err"
python3 - "$tmp/ext" <<'PY' || fail "ext block" "$tmp/ext"
import json, sys
ev = [json.loads(l) for l in open(sys.argv[1])]
log = json.dumps(ev)
assert "blocked: ext_guard: `sort hello` is not allowed" in log, "no block"
assert "blocked: ext_guard: `sed -n p hello` is not allowed" in log, "no block"
bash = [e for e in ev if e["type"] == "tool_result" and e["name"] == "bash"]
assert len(bash) == 1 and bash[0]["is_error"] and bash[0]["content"].startswith("blocked:"), bash
PY
+1 -1
View File
@@ -69,7 +69,7 @@ send(b"make hello.txt"); send(b"\r", 2)
check("permission prompt", "permission")
check("allow all edits option", "allow all edits this session")
send(b"y", 2)
check("second prompt for bash", "allow always: sort *")
check("second prompt for bash", "allow always: sed *")
send(b"y", 3)
check("tool call shown", "hello.txt")
check("tool outcome", "1 lines")