From cbed66a9baded18aa7dc938dbff5a3e40034b73b Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:26:32 +0900 Subject: [PATCH] takt: 257/add-agent-usecase-structured-o --- src/__tests__/public-api-exports.test.ts | 42 ++++++++- src/index.ts | 108 +++++------------------ 2 files changed, 63 insertions(+), 87 deletions(-) diff --git a/src/__tests__/public-api-exports.test.ts b/src/__tests__/public-api-exports.test.ts index 88de2d5..d342453 100644 --- a/src/__tests__/public-api-exports.test.ts +++ b/src/__tests__/public-api-exports.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from 'vitest'; describe('public API exports', () => { - it('should expose piece usecases and engine public APIs', async () => { + it('should expose piece usecases, engine, and piece loader APIs', async () => { // Given: パッケージの公開API const api = await import('../index.js'); - // When: 主要なユースケース関数とエンジン公開APIを参照する + // When: 主要なユースケース関数とエンジン公開API・piece読み込みAPIを参照する // Then: 必要な公開シンボルが利用できる expect(typeof api.executeAgent).toBe('function'); expect(typeof api.generateReport).toBe('function'); @@ -20,6 +20,10 @@ describe('public API exports', () => { 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'); + expect(typeof api.listPieces).toBe('function'); }); it('should not expose internal engine implementation details', async () => { @@ -36,5 +40,39 @@ describe('public API exports', () => { expect('StatusJudgmentBuilder' in api).toBe(false); expect('buildEditRule' in api).toBe(false); expect('detectRuleIndex' in api).toBe(false); + expect('ParallelLogger' in api).toBe(false); + expect('InstructionBuilder' in api).toBe(false); + expect('ReportInstructionBuilder' in api).toBe(false); + }); + + it('should not expose infrastructure implementations and internal shared utilities', async () => { + // Given: パッケージの公開API + const api = await import('../index.js'); + + // When: 非公開にすべきインフラ実装と内部ユーティリティの有無を確認する + // Then: 直接利用させない実装詳細は公開されていない + expect('ClaudeClient' in api).toBe(false); + expect('executeClaudeCli' in api).toBe(false); + expect('CodexClient' in api).toBe(false); + expect('mapToCodexSandboxMode' in api).toBe(false); + expect('getResourcesDir' in api).toBe(false); + expect('DEFAULT_PIECE_NAME' in api).toBe(false); + expect('buildPrompt' in api).toBe(false); + expect('writeFileAtomic' in api).toBe(false); + expect('getInputHistoryPath' in api).toBe(false); + expect('MAX_INPUT_HISTORY' in api).toBe(false); + expect('loadInputHistory' in api).toBe(false); + expect('saveInputHistory' in api).toBe(false); + expect('addToInputHistory' in api).toBe(false); + expect('getPersonaSessionsPath' in api).toBe(false); + expect('loadPersonaSessions' in api).toBe(false); + expect('savePersonaSessions' in api).toBe(false); + expect('updatePersonaSession' in api).toBe(false); + expect('clearPersonaSessions' in api).toBe(false); + expect('getWorktreeSessionsDir' in api).toBe(false); + expect('encodeWorktreePath' in api).toBe(false); + expect('getWorktreeSessionPath' in api).toBe(false); + expect('loadWorktreeSessions' in api).toBe(false); + expect('updateWorktreeSession' in api).toBe(false); }); }); diff --git a/src/index.ts b/src/index.ts index e2383ce..8f3b548 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,12 +5,30 @@ */ // Models -export * from './core/models/index.js'; +export type { + Status, + PieceRule, + PieceMovement, + PieceConfig, + PieceState, + Language, + PartDefinition, + PartResult, +} from './core/models/types.js'; -// Configuration (PermissionMode excluded to avoid name conflict with core/models PermissionMode) -export * from './infra/config/paths.js'; -export * from './infra/config/loaders/index.js'; -export * from './infra/config/global/index.js'; +// Configuration +export { + loadPiece, + loadPieceByIdentifier, + listPieces, + listPieceEntries, + loadAllPieces, + loadAllPiecesWithSources, + getPieceDescription, + getBuiltinPiece, + isPiecePath, +} from './infra/config/loaders/index.js'; +export type { PieceSource, PieceWithSource, PieceDirEntry } from './infra/config/loaders/index.js'; export { loadProjectConfig, saveProjectConfig, @@ -19,74 +37,8 @@ export { setCurrentPiece, isVerboseMode, type ProjectLocalConfig, - writeFileAtomic, - getInputHistoryPath, - MAX_INPUT_HISTORY, - loadInputHistory, - saveInputHistory, - addToInputHistory, - type PersonaSessionData, - getPersonaSessionsPath, - loadPersonaSessions, - savePersonaSessions, - updatePersonaSession, - clearPersonaSessions, - getWorktreeSessionsDir, - encodeWorktreePath, - getWorktreeSessionPath, - loadWorktreeSessions, - updateWorktreeSession, - getClaudeProjectSessionsDir, - clearClaudeProjectSessions, } from './infra/config/project/index.js'; -// Claude integration -export { - ClaudeClient, - ClaudeProcess, - QueryExecutor, - QueryRegistry, - executeClaudeCli, - executeClaudeQuery, - generateQueryId, - hasActiveProcess, - isQueryActive, - getActiveQueryCount, - registerQuery, - unregisterQuery, - interruptQuery, - interruptAllQueries, - interruptCurrentProcess, - sdkMessageToStreamEvent, - createCanUseToolCallback, - createAskUserQuestionHooks, - buildSdkOptions, -} from './infra/claude/index.js'; -export type { - StreamEvent, - StreamCallback, - PermissionRequest, - PermissionHandler, - AskUserQuestionInput, - AskUserQuestionHandler, - ClaudeResult, - ClaudeResultWithQueryId, - ClaudeCallOptions, - ClaudeSpawnOptions, - InitEventData, - ToolUseEventData, - ToolResultEventData, - ToolOutputEventData, - TextEventData, - ThinkingEventData, - ResultEventData, - ErrorEventData, -} from './infra/claude/index.js'; - -// Codex integration -export { CodexClient, mapToCodexSandboxMode } from './infra/codex/index.js'; -export type { CodexCallOptions, CodexSandboxMode } from './infra/codex/index.js'; - // Piece engine export { PieceEngine, @@ -100,10 +52,7 @@ export { addUserInput, getPreviousOutput, handleBlocked, - ParallelLogger, - InstructionBuilder, isOutputContractItem, - ReportInstructionBuilder, executeAgent, generateReport, executePart, @@ -123,14 +72,3 @@ export type { JudgeStatusResult, BlockedHandlerResult, } from './core/piece/index.js'; - -// Utilities -export * from './shared/utils/index.js'; -export * from './shared/ui/index.js'; -export * from './shared/prompt/index.js'; -export * from './shared/constants.js'; -export * from './shared/context.js'; -export * from './shared/exitCodes.js'; - -// Resources (embedded prompts and templates) -export * from './infra/resources/index.js';