takt/src/__tests__/claude-provider-abort-signal.test.ts
Junichi Kato b8b64f858b
feat: プロジェクト単位のCLIパス設定(Claude/Cursor/Codex) (#413)
* feat: プロジェクト単位のCLIパス設定を支援するconfig層を追加

validateCliPath汎用関数、Global/Project設定スキーマ拡張、
env override、3プロバイダ向けresolve関数(env→project→global→undefined)を追加。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: Claude/Cursor/CodexプロバイダにCLIパス解決を統合

各プロバイダのtoXxxOptions()でproject configを読み込み、
resolveXxxCliPath()経由でCLIパスを解決してSDKに渡す。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: per-project CLIパス機能のテストを追加

validateCliPath, resolveClaudeCliPath, resolveCursorCliPath,
resolveCodexCliPath(project config層)のユニットテスト、
および既存プロバイダテストのモック更新。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 09:44:16 +09:00

55 lines
1.5 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { AgentSetup } from '../infra/providers/types.js';
const {
mockCallClaude,
mockResolveAnthropicApiKey,
} = vi.hoisted(() => ({
mockCallClaude: vi.fn(),
mockResolveAnthropicApiKey: vi.fn(),
}));
vi.mock('../infra/claude/client.js', () => ({
callClaude: mockCallClaude,
callClaudeCustom: vi.fn(),
callClaudeAgent: vi.fn(),
callClaudeSkill: vi.fn(),
}));
vi.mock('../infra/config/index.js', () => ({
resolveAnthropicApiKey: mockResolveAnthropicApiKey,
resolveClaudeCliPath: vi.fn(() => undefined),
loadProjectConfig: vi.fn(() => ({})),
}));
import { ClaudeProvider } from '../infra/providers/claude.js';
describe('ClaudeProvider abortSignal wiring', () => {
beforeEach(() => {
vi.clearAllMocks();
mockResolveAnthropicApiKey.mockReturnValue(undefined);
mockCallClaude.mockResolvedValue({
persona: 'coder',
status: 'done',
content: 'ok',
timestamp: new Date(),
});
});
it('ProviderCallOptions.abortSignal を Claude call options に渡す', async () => {
const provider = new ClaudeProvider();
const setup: AgentSetup = { name: 'coder' };
const agent = provider.setup(setup);
const controller = new AbortController();
await agent.call('test prompt', {
cwd: '/tmp/project',
abortSignal: controller.signal,
});
expect(mockCallClaude).toHaveBeenCalledTimes(1);
const callOptions = mockCallClaude.mock.calls[0]?.[2];
expect(callOptions).toHaveProperty('abortSignal', controller.signal);
});
});