takt: 257/add-agent-usecase-structured-o
This commit is contained in:
parent
bcf38a5530
commit
cbed66a9ba
@ -1,11 +1,11 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
describe('public API exports', () => {
|
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
|
// Given: パッケージの公開API
|
||||||
const api = await import('../index.js');
|
const api = await import('../index.js');
|
||||||
|
|
||||||
// When: 主要なユースケース関数とエンジン公開APIを参照する
|
// When: 主要なユースケース関数とエンジン公開API・piece読み込みAPIを参照する
|
||||||
// Then: 必要な公開シンボルが利用できる
|
// Then: 必要な公開シンボルが利用できる
|
||||||
expect(typeof api.executeAgent).toBe('function');
|
expect(typeof api.executeAgent).toBe('function');
|
||||||
expect(typeof api.generateReport).toBe('function');
|
expect(typeof api.generateReport).toBe('function');
|
||||||
@ -20,6 +20,10 @@ describe('public API exports', () => {
|
|||||||
expect(typeof api.getPreviousOutput).toBe('function');
|
expect(typeof api.getPreviousOutput).toBe('function');
|
||||||
expect(api.COMPLETE_MOVEMENT).toBeDefined();
|
expect(api.COMPLETE_MOVEMENT).toBeDefined();
|
||||||
expect(api.ABORT_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 () => {
|
it('should not expose internal engine implementation details', async () => {
|
||||||
@ -36,5 +40,39 @@ describe('public API exports', () => {
|
|||||||
expect('StatusJudgmentBuilder' in api).toBe(false);
|
expect('StatusJudgmentBuilder' in api).toBe(false);
|
||||||
expect('buildEditRule' in api).toBe(false);
|
expect('buildEditRule' in api).toBe(false);
|
||||||
expect('detectRuleIndex' 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
108
src/index.ts
108
src/index.ts
@ -5,12 +5,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Models
|
// 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)
|
// Configuration
|
||||||
export * from './infra/config/paths.js';
|
export {
|
||||||
export * from './infra/config/loaders/index.js';
|
loadPiece,
|
||||||
export * from './infra/config/global/index.js';
|
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 {
|
export {
|
||||||
loadProjectConfig,
|
loadProjectConfig,
|
||||||
saveProjectConfig,
|
saveProjectConfig,
|
||||||
@ -19,74 +37,8 @@ export {
|
|||||||
setCurrentPiece,
|
setCurrentPiece,
|
||||||
isVerboseMode,
|
isVerboseMode,
|
||||||
type ProjectLocalConfig,
|
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';
|
} 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
|
// Piece engine
|
||||||
export {
|
export {
|
||||||
PieceEngine,
|
PieceEngine,
|
||||||
@ -100,10 +52,7 @@ export {
|
|||||||
addUserInput,
|
addUserInput,
|
||||||
getPreviousOutput,
|
getPreviousOutput,
|
||||||
handleBlocked,
|
handleBlocked,
|
||||||
ParallelLogger,
|
|
||||||
InstructionBuilder,
|
|
||||||
isOutputContractItem,
|
isOutputContractItem,
|
||||||
ReportInstructionBuilder,
|
|
||||||
executeAgent,
|
executeAgent,
|
||||||
generateReport,
|
generateReport,
|
||||||
executePart,
|
executePart,
|
||||||
@ -123,14 +72,3 @@ export type {
|
|||||||
JudgeStatusResult,
|
JudgeStatusResult,
|
||||||
BlockedHandlerResult,
|
BlockedHandlerResult,
|
||||||
} from './core/piece/index.js';
|
} 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';
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user