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>
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { ToolUsageRecorder } from '../src/tool-usage.js';
|
|
|
|
function assistant(blocks: unknown[]) {
|
|
return { type: 'assistant', message: { content: blocks } };
|
|
}
|
|
|
|
describe('ToolUsageRecorder', () => {
|
|
it('records tool names and Bash commands from assistant tool_use blocks', () => {
|
|
const recorder = new ToolUsageRecorder();
|
|
recorder.recordAssistantMessage(
|
|
assistant([
|
|
{ type: 'text', text: 'checking' },
|
|
{ type: 'tool_use', name: 'Read', input: { file_path: '/a' } },
|
|
{ type: 'tool_use', name: 'Bash', input: { command: 'git status' } },
|
|
]),
|
|
);
|
|
recorder.recordAssistantMessage(
|
|
assistant([{ type: 'tool_use', name: 'Edit', input: {} }]),
|
|
);
|
|
|
|
expect(recorder.snapshot()).toEqual({
|
|
tools: ['Read', 'Bash', 'Edit'],
|
|
bashCommands: ['git status'],
|
|
});
|
|
});
|
|
|
|
it('marks the report truncated when a Bash command cannot be read', () => {
|
|
const recorder = new ToolUsageRecorder();
|
|
recorder.recordAssistantMessage(
|
|
assistant([{ type: 'tool_use', name: 'Bash', input: {} }]),
|
|
);
|
|
expect(recorder.snapshot().truncated).toBe(true);
|
|
});
|
|
|
|
it('marks the report truncated instead of keeping oversized commands', () => {
|
|
const recorder = new ToolUsageRecorder();
|
|
recorder.recordAssistantMessage(
|
|
assistant([
|
|
{
|
|
type: 'tool_use',
|
|
name: 'Bash',
|
|
input: { command: 'x'.repeat(5000) },
|
|
},
|
|
]),
|
|
);
|
|
const usage = recorder.snapshot();
|
|
expect(usage.bashCommands).toEqual([]);
|
|
expect(usage.truncated).toBe(true);
|
|
});
|
|
|
|
it('ignores messages without content blocks', () => {
|
|
const recorder = new ToolUsageRecorder();
|
|
recorder.recordAssistantMessage({ type: 'assistant' });
|
|
expect(recorder.snapshot()).toEqual({ tools: [], bashCommands: [] });
|
|
});
|
|
});
|