diff --git a/src/__tests__/client.test.ts b/src/__tests__/client.test.ts index fdb0652..a44cfa4 100644 --- a/src/__tests__/client.test.ts +++ b/src/__tests__/client.test.ts @@ -3,10 +3,8 @@ */ import { describe, it, expect } from 'vitest'; -import { - detectRuleIndex, - isRegexSafe, -} from '../infra/claude/client.js'; +import { isRegexSafe } from '../infra/claude/utils.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; describe('isRegexSafe', () => { it('should accept simple patterns', () => { diff --git a/src/__tests__/it-error-recovery.test.ts b/src/__tests__/it-error-recovery.test.ts index 5df4423..4375c31 100644 --- a/src/__tests__/it-error-recovery.test.ts +++ b/src/__tests__/it-error-recovery.test.ts @@ -14,7 +14,7 @@ import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { setMockScenario, resetScenario } from '../infra/mock/index.js'; import type { PieceConfig, PieceMovement, PieceRule } from '../core/models/index.js'; -import { detectRuleIndex } from '../infra/claude/index.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; import { makeRule } from './test-helpers.js'; import { callAiJudge } from '../agents/ai-judge.js'; diff --git a/src/__tests__/it-piece-execution.test.ts b/src/__tests__/it-piece-execution.test.ts index dd40656..78e2851 100644 --- a/src/__tests__/it-piece-execution.test.ts +++ b/src/__tests__/it-piece-execution.test.ts @@ -15,7 +15,7 @@ import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { setMockScenario, resetScenario } from '../infra/mock/index.js'; import type { PieceConfig, PieceMovement, PieceRule } from '../core/models/index.js'; -import { detectRuleIndex } from '../infra/claude/index.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; import { makeRule } from './test-helpers.js'; import { callAiJudge } from '../agents/ai-judge.js'; diff --git a/src/__tests__/it-piece-patterns.test.ts b/src/__tests__/it-piece-patterns.test.ts index 4ea6d59..081af86 100644 --- a/src/__tests__/it-piece-patterns.test.ts +++ b/src/__tests__/it-piece-patterns.test.ts @@ -13,7 +13,7 @@ import { mkdtempSync, mkdirSync, rmSync } from 'node:fs'; import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { setMockScenario, resetScenario } from '../infra/mock/index.js'; -import { detectRuleIndex } from '../infra/claude/index.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; import { callAiJudge } from '../agents/ai-judge.js'; // --- Mocks --- diff --git a/src/__tests__/it-rule-evaluation.test.ts b/src/__tests__/it-rule-evaluation.test.ts index b423f29..57ec9cc 100644 --- a/src/__tests__/it-rule-evaluation.test.ts +++ b/src/__tests__/it-rule-evaluation.test.ts @@ -36,7 +36,7 @@ vi.mock('../infra/config/project/projectConfig.js', () => ({ import { evaluateAggregateConditions } from '../core/piece/index.js'; import { detectMatchedRule } from '../core/piece/evaluation/index.js'; -import { detectRuleIndex } from '../infra/claude/index.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; import type { RuleMatch, RuleEvaluatorContext } from '../core/piece/index.js'; // --- Test helpers --- diff --git a/src/__tests__/it-three-phase-execution.test.ts b/src/__tests__/it-three-phase-execution.test.ts index 9a9bf98..a6f7d6a 100644 --- a/src/__tests__/it-three-phase-execution.test.ts +++ b/src/__tests__/it-three-phase-execution.test.ts @@ -15,7 +15,7 @@ import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { setMockScenario, resetScenario } from '../infra/mock/index.js'; import type { PieceConfig, PieceMovement, PieceRule } from '../core/models/index.js'; -import { detectRuleIndex } from '../infra/claude/index.js'; +import { detectRuleIndex } from '../shared/utils/ruleIndex.js'; import { makeRule } from './test-helpers.js'; import { callAiJudge } from '../agents/ai-judge.js'; diff --git a/src/__tests__/public-api-exports.test.ts b/src/__tests__/public-api-exports.test.ts index d342453..3ec0b57 100644 --- a/src/__tests__/public-api-exports.test.ts +++ b/src/__tests__/public-api-exports.test.ts @@ -15,11 +15,6 @@ describe('public API exports', () => { expect(typeof api.decomposeTask).toBe('function'); expect(typeof api.PieceEngine).toBe('function'); - expect(typeof api.createInitialState).toBe('function'); - expect(typeof api.addUserInput).toBe('function'); - expect(typeof api.getPreviousOutput).toBe('function'); - expect(api.COMPLETE_MOVEMENT).toBeDefined(); - expect(api.ABORT_MOVEMENT).toBeDefined(); expect(typeof api.loadPiece).toBe('function'); expect(typeof api.loadPieceByIdentifier).toBe('function'); @@ -43,6 +38,16 @@ describe('public API exports', () => { expect('ParallelLogger' in api).toBe(false); expect('InstructionBuilder' in api).toBe(false); expect('ReportInstructionBuilder' in api).toBe(false); + expect('COMPLETE_MOVEMENT' in api).toBe(false); + expect('ABORT_MOVEMENT' in api).toBe(false); + expect('ERROR_MESSAGES' in api).toBe(false); + expect('determineNextMovementByRules' in api).toBe(false); + expect('extractBlockedPrompt' in api).toBe(false); + expect('LoopDetector' in api).toBe(false); + expect('createInitialState' in api).toBe(false); + expect('addUserInput' in api).toBe(false); + expect('getPreviousOutput' in api).toBe(false); + expect('handleBlocked' in api).toBe(false); }); it('should not expose infrastructure implementations and internal shared utilities', async () => { diff --git a/src/agents/types.ts b/src/agents/types.ts index abfc0e4..dad5d17 100644 --- a/src/agents/types.ts +++ b/src/agents/types.ts @@ -2,7 +2,7 @@ * Type definitions for agent execution */ -import type { StreamCallback, PermissionHandler, AskUserQuestionHandler } from '../infra/claude/index.js'; +import type { StreamCallback, PermissionHandler, AskUserQuestionHandler } from '../infra/claude/types.js'; import type { PermissionMode, Language, McpServerConfig } from '../core/models/index.js'; export type { StreamCallback }; diff --git a/src/features/tasks/execute/pieceExecution.ts b/src/features/tasks/execute/pieceExecution.ts index 01d559c..215ad50 100644 --- a/src/features/tasks/execute/pieceExecution.ts +++ b/src/features/tasks/execute/pieceExecution.ts @@ -6,7 +6,8 @@ import { readFileSync } from 'node:fs'; import { PieceEngine, type IterationLimitRequest, type UserInputRequest } from '../../../core/piece/index.js'; import type { PieceConfig } from '../../../core/models/index.js'; import type { PieceExecutionResult, PieceExecutionOptions } from './types.js'; -import { detectRuleIndex, interruptAllQueries } from '../../../infra/claude/index.js'; +import { detectRuleIndex } from '../../../shared/utils/ruleIndex.js'; +import { interruptAllQueries } from '../../../infra/claude/query-manager.js'; import { callAiJudge } from '../../../agents/ai-judge.js'; export type { PieceExecutionResult, PieceExecutionOptions }; diff --git a/src/index.ts b/src/index.ts index 8f3b548..bd9541d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,16 +42,6 @@ export { // Piece engine export { PieceEngine, - COMPLETE_MOVEMENT, - ABORT_MOVEMENT, - ERROR_MESSAGES, - determineNextMovementByRules, - extractBlockedPrompt, - LoopDetector, - createInitialState, - addUserInput, - getPreviousOutput, - handleBlocked, isOutputContractItem, executeAgent, generateReport, @@ -67,8 +57,6 @@ export type { SessionUpdateCallback, IterationLimitCallback, PieceEngineOptions, - LoopCheckResult, ProviderType, JudgeStatusResult, - BlockedHandlerResult, } from './core/piece/index.js'; diff --git a/src/infra/claude/client.ts b/src/infra/claude/client.ts index 53b4f2c..cb568e5 100644 --- a/src/infra/claude/client.ts +++ b/src/infra/claude/client.ts @@ -11,7 +11,6 @@ import { createLogger } from '../../shared/utils/index.js'; import { loadTemplate } from '../../shared/prompts/index.js'; export type { ClaudeCallOptions } from './types.js'; -export { detectRuleIndex, isRegexSafe } from './utils.js'; const log = createLogger('client'); diff --git a/src/infra/claude/index.ts b/src/infra/claude/index.ts index 5e2cb5c..7fb5387 100644 --- a/src/infra/claude/index.ts +++ b/src/infra/claude/index.ts @@ -61,13 +61,5 @@ export { buildSdkOptions, } from './options-builder.js'; -// Client functions -export { - callClaude, - callClaudeCustom, - callClaudeAgent, - callClaudeSkill, - detectRuleIndex, - isRegexSafe, -} from './client.js'; + diff --git a/src/infra/claude/utils.ts b/src/infra/claude/utils.ts index 20322fd..1810bb0 100644 --- a/src/infra/claude/utils.ts +++ b/src/infra/claude/utils.ts @@ -1,11 +1,6 @@ /** * Utility functions for Claude client operations. - * - * Stateless helpers for rule detection and regex safety validation. */ -import { detectRuleIndex } from '../../shared/utils/ruleIndex.js'; - -export { detectRuleIndex }; /** Validate regex pattern for ReDoS safety */ export function isRegexSafe(pattern: string): boolean { diff --git a/src/infra/providers/claude.ts b/src/infra/providers/claude.ts index 81c3a2f..a47702f 100644 --- a/src/infra/providers/claude.ts +++ b/src/infra/providers/claude.ts @@ -2,7 +2,8 @@ * Claude provider implementation */ -import { callClaude, callClaudeCustom, callClaudeAgent, callClaudeSkill, type ClaudeCallOptions } from '../claude/index.js'; +import { callClaude, callClaudeCustom, callClaudeAgent, callClaudeSkill } from '../claude/client.js'; +import type { ClaudeCallOptions } from '../claude/types.js'; import { resolveAnthropicApiKey } from '../config/index.js'; import type { AgentResponse } from '../../core/models/index.js'; import type { AgentSetup, Provider, ProviderAgent, ProviderCallOptions } from './types.js';