The owner may end a TASK_DONE answer with "리뷰 불필요: <reason>". The host treats it as a request and honors it only when every guard holds: - workspace content equals the task base (hasCodeChangesSinceRef), the working tree is clean, and HEAD did not move during the owner run - the run used no file-mutating tool (Edit/Write/MultiEdit/NotebookEdit), no subagent (Agent/Task) and no state-changing or unknown MCP tool - every Bash command is classified read-only by a conservative quote-aware classifier (src/bash-command-classifier.ts); anything unknown counts as mutating - tool usage was reported and not truncated (agent-runner now reports tool names and Bash commands as toolUsage on its terminal output) - the user did not ask for a review in this task When honored the task completes as review_skipped with no reviewer or finalize turn; the answer is delivered with the marker line removed and a small "-# 검토 생략 …" note. Otherwise the marker is stripped and the normal review runs. A bare "검토해줘"-style message right after a review-skipped answer reopens that task for the reviewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
174 lines
4.6 KiB
TypeScript
174 lines
4.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { classifyBashCommand } from './bash-command-classifier.js';
|
|
|
|
const READ_ONLY = [
|
|
'ls -la',
|
|
'cat src/index.ts',
|
|
'head -50 README.md | tail -20',
|
|
'grep -rn "foo" src --include=*.ts | head',
|
|
'rg -n "a > b" src',
|
|
'wc -l src/*.ts',
|
|
'cd /home/claude/EJClaw && git status',
|
|
'git log --oneline -10',
|
|
'git -C /repo diff --stat HEAD~1',
|
|
'git --no-pager show HEAD:src/a.ts',
|
|
'git branch --show-current',
|
|
'git branch -a',
|
|
'git rev-parse HEAD^{tree}',
|
|
'git stash list',
|
|
'git remote -v',
|
|
'git config --get user.name',
|
|
'git tag',
|
|
'systemctl --user status ejclaw',
|
|
'systemctl --user show -p MainPID --value ejclaw.service',
|
|
'systemctl --user is-active ejclaw',
|
|
'journalctl --user -u ejclaw -n 50 --no-pager',
|
|
'docker ps',
|
|
'docker --context default ps -a',
|
|
'docker logs --tail 20 web',
|
|
'docker compose -f /root/x.yml ps',
|
|
'docker stats --no-stream',
|
|
'curl -s https://example.com/api',
|
|
'curl -sS -X GET https://example.com',
|
|
'curl -I https://example.com',
|
|
'wget -qO- https://example.com',
|
|
'sqlite3 -readonly store/messages.db "select count(*) from paired_tasks"',
|
|
'find . -name "*.ts" -type f',
|
|
"sed -n '1,20p' file.txt",
|
|
'sort file.txt | uniq -c',
|
|
"awk '{print $1}' file",
|
|
'gh pr view 12',
|
|
'gh run list --limit 5',
|
|
'gh api repos/o/r/pulls',
|
|
'kill -0 1234',
|
|
'crontab -l',
|
|
'ps aux | grep ejclaw',
|
|
'pgrep -f agent-runner',
|
|
'nvidia-smi',
|
|
'free -h',
|
|
'df -h /',
|
|
'du -sh data/*',
|
|
'echo hello',
|
|
'ls missing 2>/dev/null',
|
|
'ls >/dev/null 2>&1',
|
|
'cat a.txt 2>&1 | head',
|
|
'FOO=1 ls',
|
|
'timeout 10 curl -s https://example.com',
|
|
'echo "$PW" | sudo -S systemctl status nvidia',
|
|
'ls | xargs grep -l foo',
|
|
'tsc --noEmit',
|
|
'ip addr show',
|
|
'ping -c 1 192.168.10.5',
|
|
'stat -c %y file',
|
|
'test -f /etc/passwd && echo yes',
|
|
'env',
|
|
'printenv HOME',
|
|
'',
|
|
];
|
|
|
|
const MUTATING = [
|
|
'rm -rf data/tmp',
|
|
'mv a b',
|
|
'cp a b',
|
|
'mkdir -p out',
|
|
'touch file',
|
|
'ln -s a b',
|
|
'chmod +x run.sh',
|
|
'chown claude file',
|
|
'echo hi > file.txt',
|
|
'echo hi >> file.txt',
|
|
'cat a | tee b',
|
|
'ls &> out.log',
|
|
"sed -i 's/a/b/' file",
|
|
"sed -ni 's/a/b/p' file",
|
|
"sed -n 's/a/b/w out.txt' file",
|
|
'git commit -m "x"',
|
|
'git push origin main',
|
|
'git reset --hard HEAD~1',
|
|
'git checkout -b feature',
|
|
'git merge other',
|
|
'git rebase main',
|
|
'git stash push -m x',
|
|
'git stash',
|
|
'git branch new-branch',
|
|
'git branch -D old',
|
|
'git tag v1.0',
|
|
'git fetch origin',
|
|
'git -c core.hooksPath=x status',
|
|
'git add .',
|
|
'systemctl --user restart ejclaw',
|
|
'systemctl --user stop ejclaw',
|
|
'systemctl --user start ejclaw',
|
|
'systemctl --user daemon-reload',
|
|
'kill 1234',
|
|
'kill -HUP 1234',
|
|
'kill -HUP "$(systemctl --user show -p MainPID --value ejclaw.service)"',
|
|
'pkill -f runner',
|
|
'crontab -e',
|
|
'crontab file',
|
|
'sqlite3 store/messages.db "select 1"',
|
|
'sqlite3 -readonly store/messages.db "delete from t"',
|
|
'sqlite3 -readonly db "drop table t"',
|
|
'sqlite3 -readonly db "insert into t values (1)"',
|
|
'curl -X POST https://example.com/api',
|
|
'curl -XPOST https://example.com/api',
|
|
'curl --request DELETE https://example.com/x',
|
|
'curl -d "a=1" https://example.com',
|
|
'curl --data-binary @f https://example.com',
|
|
'curl -F file=@a https://example.com',
|
|
'curl -T file https://example.com',
|
|
'curl -o out.html https://example.com',
|
|
'curl -sSLO https://example.com/file',
|
|
'wget https://example.com/file',
|
|
'wget --post-data=a https://example.com',
|
|
'npm install left-pad',
|
|
'bun install',
|
|
'pip install requests',
|
|
'bun run build',
|
|
'docker run --rm alpine',
|
|
'docker rm web',
|
|
'docker stop web',
|
|
'docker compose up -d',
|
|
'docker compose down',
|
|
'docker exec web ls',
|
|
'ssh root@192.168.10.5 "docker ps"',
|
|
'find . -name "*.tmp" -delete',
|
|
'find . -exec rm {} \\;',
|
|
'sort -o out.txt in.txt',
|
|
'echo $(rm -rf x)',
|
|
'echo `whoami`',
|
|
'cat <(ls)',
|
|
'cat <<EOF > f\nhello\nEOF',
|
|
'bun -e "console.log(1)"',
|
|
'python3 -c "print(1)"',
|
|
'node script.js',
|
|
'bash -c "ls"',
|
|
'nohup ./run.sh &',
|
|
'ls; rm x',
|
|
'ls && rm x',
|
|
'ls || rm x',
|
|
'ls | xargs rm',
|
|
'gh pr merge 12',
|
|
'gh api -X POST repos/o/r/issues',
|
|
'gh api repos/o/r/issues -f title=x',
|
|
'tsc',
|
|
'for f in *; do rm $f; done',
|
|
'awk \'{ system("rm x") }\' f',
|
|
"echo 'unterminated",
|
|
'unknown-tool --flag',
|
|
'./scripts/deploy.sh',
|
|
'source .env',
|
|
'echo hi >| file',
|
|
];
|
|
|
|
describe('classifyBashCommand', () => {
|
|
it.each(READ_ONLY)('treats %j as read-only', (command) => {
|
|
expect(classifyBashCommand(command)).toBe('read_only');
|
|
});
|
|
|
|
it.each(MUTATING)('treats %j as mutating', (command) => {
|
|
expect(classifyBashCommand(command)).toBe('mutating');
|
|
});
|
|
});
|