UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

180 lines 4.36 kB
/** * Corpus Builder * * Utility for creating and exporting ground truth corpora with validation. * * @module testing/corpus/corpus-builder */ import { CorpusType, CorpusSchema, GroundTruthItem, ValidationResult } from './ground-truth-manager.js'; /** * Builder options */ export interface CorpusBuilderOptions { /** Corpus type */ type: CorpusType; /** Corpus name */ name: string; /** Corpus description */ description: string; /** Schema for ground truth validation */ schema: CorpusSchema; /** Linked NFRs */ linkedNFRs: string[]; } /** * Export options */ export interface ExportOptions { /** Output directory */ outputDir: string; /** Version string (semver) */ version: string; /** Maximum items per data file */ maxItemsPerFile?: number; } /** * CorpusBuilder - Build and export ground truth corpora * * @example * ```typescript * const builder = new CorpusBuilder({ * type: 'ai-vs-human', * name: 'AI vs Human Writing Corpus', * description: 'Labeled corpus for AI pattern detection validation', * schema: { * groundTruthType: 'boolean', * formatDescription: 'true for AI-generated, false for human-written' * }, * linkedNFRs: ['NFR-ACC-001'] * }); * * // Add items * builder.addItem({ * id: 'doc-001', * content: 'This is a sample document...', * groundTruth: true, // AI-generated * metadata: { source: 'gpt-4' } * }); * * // Validate and export * const validation = builder.validate(); * if (validation.valid) { * await builder.export({ * outputDir: './tests/fixtures/corpora', * version: '1.0.0' * }); * } * ``` */ export declare class CorpusBuilder { private options; private items; constructor(options: CorpusBuilderOptions); /** * Add an item to the corpus * * @param item - Ground truth item * @throws {Error} If item ID already exists */ addItem(item: GroundTruthItem): void; /** * Add multiple items to the corpus * * @param items - Array of ground truth items */ addItems(items: GroundTruthItem[]): void; /** * Remove an item from the corpus * * @param itemId - Item identifier * @returns True if item was removed */ removeItem(itemId: string): boolean; /** * Get an item by ID * * @param itemId - Item identifier * @returns Item or undefined */ getItem(itemId: string): GroundTruthItem | undefined; /** * Get all items * * @returns Array of all items */ getAllItems(): GroundTruthItem[]; /** * Get item count */ getItemCount(): number; /** * Clear all items */ clear(): void; /** * Validate the corpus * * @returns Validation result */ validate(): ValidationResult; /** * Validate a single item against schema */ private validateItem; /** * Calculate label distribution */ private calculateLabelDistribution; /** * Export corpus to files * * @param options - Export options * @throws {Error} If corpus is invalid */ export(options: ExportOptions): Promise<void>; /** * Split array into chunks */ private chunkArray; /** * Import items from existing JSON file * * @param filePath - Path to JSON file * @throws {Error} If file cannot be read or parsed */ importFromFile(filePath: string): Promise<void>; /** * Get corpus statistics */ getStatistics(): { itemCount: number; labelDistribution: Record<string, number>; type: CorpusType; }; } /** * Pre-configured builder factories for each corpus type */ export declare const CorpusBuilders: { /** * Create AI vs Human writing corpus builder */ aiVsHuman(): CorpusBuilder; /** * Create codebase metadata corpus builder */ codebases(): CorpusBuilder; /** * Create traceability links corpus builder */ traceability(): CorpusBuilder; /** * Create security attacks corpus builder */ securityAttacks(): CorpusBuilder; /** * Create template recommendations corpus builder */ templateRecommendations(): CorpusBuilder; }; //# sourceMappingURL=corpus-builder.d.ts.map